Exemple #1
0
 private void AddRecord(List <string> fields)
 {
     if (CurrentTable == Table.Weenie)
     {
         PopulateFields(Weenie, fields);
     }
     else if (CurrentTable == Table.AnimPart)
     {
         var record = new WeeniePropertiesAnimPart();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesAnimPart.Add(record);
     }
     else if (CurrentTable == Table.Attribute)
     {
         var record = new WeeniePropertiesAttribute();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesAttribute.Add(record);
     }
     else if (CurrentTable == Table.Attribute2nd)
     {
         var record = new WeeniePropertiesAttribute2nd();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesAttribute2nd.Add(record);
     }
     else if (CurrentTable == Table.BodyPart)
     {
         var record = new WeeniePropertiesBodyPart();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesBodyPart.Add(record);
     }
     else if (CurrentTable == Table.Book)
     {
         Weenie.WeeniePropertiesBook = new WeeniePropertiesBook();
         PopulateFields(Weenie.WeeniePropertiesBook, fields);
     }
     else if (CurrentTable == Table.BookPageData)
     {
         var record = new WeeniePropertiesBookPageData();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesBookPageData.Add(record);
     }
     else if (CurrentTable == Table.Bool)
     {
         var record = new WeeniePropertiesBool();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesBool.Add(record);
     }
     else if (CurrentTable == Table.CreateList)
     {
         var record = new WeeniePropertiesCreateList();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesCreateList.Add(record);
     }
     else if (CurrentTable == Table.DID)
     {
         var record = new WeeniePropertiesDID();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesDID.Add(record);
     }
     else if (CurrentTable == Table.Emote)
     {
         var record = new WeeniePropertiesEmote();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesEmote.Add(record);
         CurrentEmote = record;
     }
     else if (CurrentTable == Table.EmoteAction)
     {
         var record = new WeeniePropertiesEmoteAction();
         PopulateFields(record, fields);
         CurrentEmote.WeeniePropertiesEmoteAction.Add(record);
     }
     else if (CurrentTable == Table.EventFilter)
     {
         var record = new WeeniePropertiesEventFilter();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesEventFilter.Add(record);
     }
     else if (CurrentTable == Table.Float)
     {
         var record = new WeeniePropertiesFloat();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesFloat.Add(record);
     }
     else if (CurrentTable == Table.Generator)
     {
         var record = new WeeniePropertiesGenerator();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesGenerator.Add(record);
     }
     else if (CurrentTable == Table.IID)
     {
         var record = new WeeniePropertiesIID();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesIID.Add(record);
     }
     else if (CurrentTable == Table.Int)
     {
         var record = new WeeniePropertiesInt();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesInt.Add(record);
     }
     else if (CurrentTable == Table.Int64)
     {
         var record = new WeeniePropertiesInt64();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesInt64.Add(record);
     }
     else if (CurrentTable == Table.Palette)
     {
         var record = new WeeniePropertiesPalette();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesPalette.Add(record);
     }
     else if (CurrentTable == Table.Position)
     {
         var record = new WeeniePropertiesPosition();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesPosition.Add(record);
     }
     else if (CurrentTable == Table.Skill)
     {
         var record = new WeeniePropertiesSkill();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesSkill.Add(record);
     }
     else if (CurrentTable == Table.SpellBook)
     {
         var record = new WeeniePropertiesSpellBook();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesSpellBook.Add(record);
     }
     else if (CurrentTable == Table.String)
     {
         var record = new WeeniePropertiesString();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesString.Add(record);
     }
     else if (CurrentTable == Table.TextureMap)
     {
         var record = new WeeniePropertiesTextureMap();
         PopulateFields(record, fields);
         Weenie.WeeniePropertiesTextureMap.Add(record);
     }
 }
Exemple #2
0
 private static int CalculateEmoteHash(WeeniePropertiesEmote emote)
 {
     return(CalculateEmoteHash(emote.Category, emote.Probability, emote.WeenieClassId, emote.Style, emote.Substyle, emote.Quest, emote.VendorType));
 }
        public static Weenie ConvertToACE(this KeyValuePair <uint, Seg9_WeenieDefaults.Weenie> input)
        {
            var result = new Weenie();

            result.ClassId = input.Key;
            WeenieClassNames.Values.TryGetValue(input.Value.WCID, out var className);
            result.ClassName = className;
            result.Type      = input.Value.WeenieType;

            if (input.Value.IntValues != null)
            {
                foreach (var value in input.Value.IntValues)
                {
                    result.WeeniePropertiesInt.Add(new WeeniePropertiesInt {
                        Type = (ushort)value.Key, Value = value.Value
                    });
                }
            }

            if (input.Value.LongValues != null)
            {
                foreach (var value in input.Value.LongValues)
                {
                    result.WeeniePropertiesInt64.Add(new WeeniePropertiesInt64 {
                        Type = (ushort)value.Key, Value = value.Value
                    });
                }
            }

            if (input.Value.BoolValues != null)
            {
                foreach (var value in input.Value.BoolValues)
                {
                    result.WeeniePropertiesBool.Add(new WeeniePropertiesBool {
                        Type = (ushort)value.Key, Value = value.Value
                    });
                }
            }

            if (input.Value.DoubleValues != null)
            {
                foreach (var value in input.Value.DoubleValues)
                {
                    result.WeeniePropertiesFloat.Add(new WeeniePropertiesFloat {
                        Type = (ushort)value.Key, Value = value.Value
                    });
                }
            }

            if (input.Value.StringValues != null)
            {
                foreach (var value in input.Value.StringValues)
                {
                    if (value.Key == (int)PropertyString.Name)
                    {
                        var propertyValue = value.Value;

                        // For some reason, in the cache.bin, the names of some weenies have been nulled out.
                        // When we find this to be the case, we generate a name from a known list
                        if (String.IsNullOrEmpty(propertyValue))
                        {
                            propertyValue = result.ClassName;
                        }

                        result.WeeniePropertiesString.Add(new WeeniePropertiesString {
                            Type = (ushort)value.Key, Value = propertyValue
                        });
                    }
                    else
                    {
                        result.WeeniePropertiesString.Add(new WeeniePropertiesString {
                            Type = (ushort)value.Key, Value = value.Value
                        });
                    }
                }
            }

            if (input.Value.DIDValues != null)
            {
                foreach (var value in input.Value.DIDValues)
                {
                    result.WeeniePropertiesDID.Add(new WeeniePropertiesDID {
                        Type = (ushort)value.Key, Value = value.Value
                    });
                }
            }

            if (input.Value.PositionValues != null)
            {
                foreach (var value in input.Value.PositionValues)
                {
                    result.WeeniePropertiesPosition.Add(new WeeniePropertiesPosition()
                    {
                        PositionType = (ushort)value.Key,

                        ObjCellId = value.Value.ObjCellID,
                        OriginX   = value.Value.Origin.X,
                        OriginY   = value.Value.Origin.Y,
                        OriginZ   = value.Value.Origin.Z,
                        AnglesW   = value.Value.Angles.W,
                        AnglesX   = value.Value.Angles.X,
                        AnglesY   = value.Value.Angles.Y,
                        AnglesZ   = value.Value.Angles.Z,
                    });
                }
            }

            if (input.Value.IIDValues != null)
            {
                foreach (var value in input.Value.IIDValues)
                {
                    result.WeeniePropertiesIID.Add(new WeeniePropertiesIID {
                        Type = (ushort)value.Key, Value = value.Value
                    });
                }
            }

            if (input.Value.Attributes != null)
            {
                result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                    Type = (ushort)PropertyAttribute.Strength, InitLevel = input.Value.Attributes.Strength.InitLevel, LevelFromCP = input.Value.Attributes.Strength.LevelFromCP, CPSpent = input.Value.Attributes.Strength.CPSpent
                });
                result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                    Type = (ushort)PropertyAttribute.Endurance, InitLevel = input.Value.Attributes.Endurance.InitLevel, LevelFromCP = input.Value.Attributes.Endurance.LevelFromCP, CPSpent = input.Value.Attributes.Endurance.CPSpent
                });
                result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                    Type = (ushort)PropertyAttribute.Quickness, InitLevel = input.Value.Attributes.Quickness.InitLevel, LevelFromCP = input.Value.Attributes.Quickness.LevelFromCP, CPSpent = input.Value.Attributes.Quickness.CPSpent
                });
                result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                    Type = (ushort)PropertyAttribute.Coordination, InitLevel = input.Value.Attributes.Coordination.InitLevel, LevelFromCP = input.Value.Attributes.Coordination.LevelFromCP, CPSpent = input.Value.Attributes.Coordination.CPSpent
                });
                result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                    Type = (ushort)PropertyAttribute.Focus, InitLevel = input.Value.Attributes.Focus.InitLevel, LevelFromCP = input.Value.Attributes.Focus.LevelFromCP, CPSpent = input.Value.Attributes.Focus.CPSpent
                });
                result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                    Type = (ushort)PropertyAttribute.Self, InitLevel = input.Value.Attributes.Self.InitLevel, LevelFromCP = input.Value.Attributes.Self.LevelFromCP, CPSpent = input.Value.Attributes.Self.CPSpent
                });

                result.WeeniePropertiesAttribute2nd.Add(new WeeniePropertiesAttribute2nd {
                    Type = (ushort)PropertyAttribute2nd.MaxHealth, InitLevel = input.Value.Attributes.Health.InitLevel, LevelFromCP = input.Value.Attributes.Health.LevelFromCP, CPSpent = input.Value.Attributes.Health.CPSpent, CurrentLevel = input.Value.Attributes.Health.Current
                });
                result.WeeniePropertiesAttribute2nd.Add(new WeeniePropertiesAttribute2nd {
                    Type = (ushort)PropertyAttribute2nd.MaxStamina, InitLevel = input.Value.Attributes.Stamina.InitLevel, LevelFromCP = input.Value.Attributes.Stamina.LevelFromCP, CPSpent = input.Value.Attributes.Stamina.CPSpent, CurrentLevel = input.Value.Attributes.Stamina.Current
                });
                result.WeeniePropertiesAttribute2nd.Add(new WeeniePropertiesAttribute2nd {
                    Type = (ushort)PropertyAttribute2nd.MaxMana, InitLevel = input.Value.Attributes.Mana.InitLevel, LevelFromCP = input.Value.Attributes.Mana.LevelFromCP, CPSpent = input.Value.Attributes.Mana.CPSpent, CurrentLevel = input.Value.Attributes.Mana.Current
                });
            }

            if (input.Value.Skills != null)
            {
                foreach (var value in input.Value.Skills)
                {
                    result.WeeniePropertiesSkill.Add(new WeeniePropertiesSkill {
                        Type = (ushort)value.Key, LevelFromPP = value.Value.LevelFromPP, SAC = value.Value.Sac, PP = value.Value.PP, InitLevel = value.Value.InitLevel, ResistanceAtLastCheck = value.Value.ResistanceAtLastCheck, LastUsedTime = value.Value.LastUsedTime
                    });
                }
            }

            if (input.Value.BodyParts != null)
            {
                foreach (var value in input.Value.BodyParts)
                {
                    result.WeeniePropertiesBodyPart.Add(new WeeniePropertiesBodyPart
                    {
                        Key = (ushort)value.Key,

                        DType = value.Value.DType,
                        DVal  = value.Value.DVal,
                        DVar  = value.Value.DVar,

                        BaseArmor       = value.Value.ArmorValues.BaseArmor,
                        ArmorVsSlash    = value.Value.ArmorValues.ArmorVsSlash,
                        ArmorVsPierce   = value.Value.ArmorValues.ArmorVsPierce,
                        ArmorVsBludgeon = value.Value.ArmorValues.ArmorVsBludgeon,
                        ArmorVsCold     = value.Value.ArmorValues.ArmorVsCold,
                        ArmorVsFire     = value.Value.ArmorValues.ArmorVsFire,
                        ArmorVsAcid     = value.Value.ArmorValues.ArmorVsAcid,
                        ArmorVsElectric = value.Value.ArmorValues.ArmorVsElectric,
                        ArmorVsNether   = value.Value.ArmorValues.ArmorVsNether,

                        BH = value.Value.BH,

                        HLF = value.Value.SD.HLF,
                        MLF = value.Value.SD.MLF,
                        LLF = value.Value.SD.LLF,

                        HRF = value.Value.SD.HRF,
                        MRF = value.Value.SD.MRF,
                        LRF = value.Value.SD.LRF,

                        HLB = value.Value.SD.HLB,
                        MLB = value.Value.SD.MLB,
                        LLB = value.Value.SD.LLB,

                        HRB = value.Value.SD.HRB,
                        MRB = value.Value.SD.MRB,
                        LRB = value.Value.SD.LRB,
                    });
                }
            }

            if (input.Value.SpellCastingProbability != null)
            {
                foreach (var value in input.Value.SpellCastingProbability)
                {
                    result.WeeniePropertiesSpellBook.Add(new WeeniePropertiesSpellBook {
                        Spell = value.Key, Probability = value.Value
                    });
                }
            }

            if (input.Value.EventFilters != null)
            {
                foreach (var value in input.Value.EventFilters)
                {
                    result.WeeniePropertiesEventFilter.Add(new WeeniePropertiesEventFilter {
                        Event = value
                    });
                }
            }

            if (input.Value.Emotes != null)
            {
                foreach (var kvp in input.Value.Emotes)
                {
                    // kvp.key not used

                    foreach (var value in kvp.Value)
                    {
                        var efEmote = new WeeniePropertiesEmote
                        {
                            Category = value.Category,

                            Probability = value.Probability,

                            WeenieClassId = value.ClassID,

                            Style    = value.Style,
                            Substyle = value.Substyle,

                            Quest = value.Quest,

                            VendorType = value.VendorType,

                            MinHealth = value.MinHealth,
                            MaxHealth = value.MaxHealth
                        };

                        uint order = 0;

                        foreach (var action in value.EmoteActions)
                        {
                            var efAction = new WeeniePropertiesEmoteAction
                            {
                                Order = order, // This is an ACE specific value to maintain the correct order of EmoteActions

                                Type   = action.Type,
                                Delay  = action.Delay,
                                Extent = action.Extent,

                                Motion = action.Motion,

                                Message    = action.Message,
                                TestString = action.TestString,

                                Min    = action.Min,
                                Max    = action.Max,
                                Min64  = action.Min64,
                                Max64  = action.Max64,
                                MinDbl = action.MinDbl,
                                MaxDbl = action.MaxDbl,

                                Stat    = action.Stat,
                                Display = action.Display,

                                Amount   = action.Amount,
                                Amount64 = action.Amount64,
                                HeroXP64 = action.HeroXP64,

                                Percent = action.Percent,

                                SpellId = action.SpellID,

                                WealthRating  = action.WealthRating,
                                TreasureClass = action.TreasureClass,
                                TreasureType  = action.TreasureType,

                                PScript = action.PScript,

                                Sound = action.Sound
                            };

                            order++;

                            if (action.Item != null)
                            {
                                efAction.WeenieClassId   = action.Item.WCID;
                                efAction.Palette         = action.Item.Palette;
                                efAction.Shade           = action.Item.Shade;
                                efAction.DestinationType = action.Item.Destination;
                                efAction.StackSize       = action.Item.StackSize;
                                efAction.TryToBond       = action.Item.TryToBond;
                            }

                            if (action.Frame != null)
                            {
                                efAction.OriginX = action.Frame.Origin.X;
                                efAction.OriginY = action.Frame.Origin.Y;
                                efAction.OriginZ = action.Frame.Origin.Z;

                                efAction.AnglesW = action.Frame.Angles.W;
                                efAction.AnglesX = action.Frame.Angles.X;
                                efAction.AnglesY = action.Frame.Angles.Y;
                                efAction.AnglesZ = action.Frame.Angles.Z;
                            }

                            if (action.Position != null)
                            {
                                efAction.ObjCellId = action.Position.ObjCellID;

                                efAction.OriginX = action.Position.Origin.X;
                                efAction.OriginY = action.Position.Origin.Y;
                                efAction.OriginZ = action.Position.Origin.Z;

                                efAction.AnglesW = action.Position.Angles.W;
                                efAction.AnglesX = action.Position.Angles.X;
                                efAction.AnglesY = action.Position.Angles.Y;
                                efAction.AnglesZ = action.Position.Angles.Z;
                            }

                            efEmote.WeeniePropertiesEmoteAction.Add(efAction);
                        }

                        result.WeeniePropertiesEmote.Add(efEmote);
                    }
                }
            }

            if (input.Value.CreateList != null)
            {
                foreach (var value in input.Value.CreateList)
                {
                    result.WeeniePropertiesCreateList.Add(new WeeniePropertiesCreateList {
                        WeenieClassId = value.WCID, Palette = value.Palette, Shade = value.Shade, DestinationType = value.Destination, StackSize = value.StackSize, TryToBond = value.TryToBond
                    });
                }
            }

            if (input.Value.PagesData != null)
            {
                result.WeeniePropertiesBook = new WeeniePropertiesBook {
                    MaxNumPages = input.Value.PagesData.MaxNumPages, MaxNumCharsPerPage = input.Value.PagesData.MaxNumCharsPerPage
                };

                if (input.Value.PagesData.Pages != null)
                {
                    uint pageId = 0;

                    foreach (var value in input.Value.PagesData.Pages)
                    {
                        result.WeeniePropertiesBookPageData.Add(new WeeniePropertiesBookPageData
                        {
                            PageId = pageId,

                            AuthorId      = value.AuthorID,
                            AuthorName    = value.AuthorName ?? "", // todo: Fix these strings in the db context so they can be null
                            AuthorAccount = value.AuthorAccount,
                            IgnoreAuthor  = value.IgnoreAuthor,
                            PageText      = value.Text
                        });

                        pageId++;
                    }
                }
            }

            if (input.Value.Generators != null)
            {
                foreach (var value in input.Value.Generators)
                {
                    result.WeeniePropertiesGenerator.Add(new WeeniePropertiesGenerator
                    {
                        Probability   = value.Probability,
                        WeenieClassId = value.Type,
                        Delay         = (float?)value.Delay, // todo Can be null. Is there a default null value in the cache.bin? (might be 0)

                        InitCreate = value.InitCreate,
                        MaxCreate  = value.MaxNum,

                        WhenCreate  = value.WhenCreate,
                        WhereCreate = value.WhereCreate,

                        StackSize = value.StackSize,     // todo Can be null. Is there a default null value in the cache.bin? (might be -1)

                        PaletteId = value.PalleteTypeID, // todo Can be null. Is there a default null value in the cache.bin? (might be 0)
                        Shade     = value.Shade,         // todo Can be null. Is there a default null value in the cache.bin? (might be 0)

                        // todo Can be null. Is there a default null value in the cache.bin?
                        ObjCellId = value.Position.ObjCellID,
                        OriginX   = value.Position.Origin.X,
                        OriginY   = value.Position.Origin.Y,
                        OriginZ   = value.Position.Origin.Z,
                        AnglesW   = value.Position.Angles.W,
                        AnglesX   = value.Position.Angles.X,
                        AnglesY   = value.Position.Angles.Y,
                        AnglesZ   = value.Position.Angles.Z,

                        // Slot
                    });
                }
            }


            if (input.Value.Palette != null)
            {
                foreach (var value in input.Value.Palette.SubPalettes)
                {
                    result.WeeniePropertiesPalette.Add(new WeeniePropertiesPalette {
                        SubPaletteId = (uint)value.ID, Offset = value.Offset, Length = value.NumberOfColors
                    });
                }
            }

            if (input.Value.TextureMaps != null)
            {
                foreach (var value in input.Value.TextureMaps)
                {
                    result.WeeniePropertiesTextureMap.Add(new WeeniePropertiesTextureMap {
                        Index = value.Index, OldId = (uint)value.OldTextureID, NewId = (uint)value.NewTextureID
                    });
                }
            }

            if (input.Value.AnimParts != null)
            {
                foreach (var value in input.Value.AnimParts)
                {
                    result.WeeniePropertiesAnimPart.Add(new WeeniePropertiesAnimPart {
                        Index = value.Index, Id = (uint)value.ID
                    });
                }
            }

            return(result);
        }
Exemple #4
0
        public static bool TryConvert(global::Lifestoned.DataModel.Gdle.Weenie input, out Weenie result)
        {
            try
            {
                result = new Weenie();

                result.ClassId = input.WeenieId;
                //weenie.ClassName;
                result.Type = input.WeenieTypeId;

                if (input.Book != null)
                {
                    result.WeeniePropertiesBook                    = new WeeniePropertiesBook();
                    result.WeeniePropertiesBook.MaxNumPages        = result.WeeniePropertiesBook.MaxNumPages;
                    result.WeeniePropertiesBook.MaxNumCharsPerPage = result.WeeniePropertiesBook.MaxNumCharsPerPage;

                    if (input.Book.Pages != null)
                    {
                        result.WeeniePropertiesBookPageData = new List <WeeniePropertiesBookPageData>();

                        uint pageId = 0;

                        foreach (var value in input.Book.Pages)
                        {
                            result.WeeniePropertiesBookPageData.Add(new WeeniePropertiesBookPageData
                            {
                                PageId = pageId,

                                AuthorId      = value.AuthorId ?? 0,
                                AuthorName    = value.AuthorName,
                                AuthorAccount = value.AuthorAccount,
                                IgnoreAuthor  = value.IgnoreAuthor ?? false,
                                PageText      = value.PageText,
                            });

                            pageId++;
                        }
                    }
                }

                // LandblockInstance

                // PointsOfInterest

                // WeeniePropertiesAnimPart

                if (input.Attributes != null)
                {
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Strength, InitLevel = input.Attributes.Strength.Ranks ?? 0, LevelFromCP = input.Attributes.Strength.LevelFromCp, CPSpent = input.Attributes.Strength.XpSpent ?? 0
                    });
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Endurance, InitLevel = input.Attributes.Endurance.Ranks ?? 0, LevelFromCP = input.Attributes.Endurance.LevelFromCp, CPSpent = input.Attributes.Endurance.XpSpent ?? 0
                    });
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Quickness, InitLevel = input.Attributes.Quickness.Ranks ?? 0, LevelFromCP = input.Attributes.Quickness.LevelFromCp, CPSpent = input.Attributes.Quickness.XpSpent ?? 0
                    });
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Coordination, InitLevel = input.Attributes.Coordination.Ranks ?? 0, LevelFromCP = input.Attributes.Coordination.LevelFromCp, CPSpent = input.Attributes.Coordination.XpSpent ?? 0
                    });
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Focus, InitLevel = input.Attributes.Focus.Ranks ?? 0, LevelFromCP = input.Attributes.Focus.LevelFromCp, CPSpent = input.Attributes.Focus.XpSpent ?? 0
                    });
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Self, InitLevel = input.Attributes.Self.Ranks ?? 0, LevelFromCP = input.Attributes.Self.LevelFromCp, CPSpent = input.Attributes.Self.XpSpent ?? 0
                    });

                    result.WeeniePropertiesAttribute2nd.Add(new WeeniePropertiesAttribute2nd {
                        Type = (ushort)PropertyAttribute2nd.MaxHealth, InitLevel = input.Attributes.Health.Ranks ?? 0, LevelFromCP = input.Attributes.Health.LevelFromCp ?? 0, CPSpent = input.Attributes.Health.XpSpent ?? 0, CurrentLevel = input.Attributes.Health.Current ?? 0
                    });
                    result.WeeniePropertiesAttribute2nd.Add(new WeeniePropertiesAttribute2nd {
                        Type = (ushort)PropertyAttribute2nd.MaxStamina, InitLevel = input.Attributes.Stamina.Ranks ?? 0, LevelFromCP = input.Attributes.Stamina.LevelFromCp ?? 0, CPSpent = input.Attributes.Stamina.XpSpent ?? 0, CurrentLevel = input.Attributes.Stamina.Current ?? 0
                    });
                    result.WeeniePropertiesAttribute2nd.Add(new WeeniePropertiesAttribute2nd {
                        Type = (ushort)PropertyAttribute2nd.MaxMana, InitLevel = input.Attributes.Mana.Ranks ?? 0, LevelFromCP = input.Attributes.Mana.LevelFromCp ?? 0, CPSpent = input.Attributes.Mana.XpSpent ?? 0, CurrentLevel = input.Attributes.Mana.Current ?? 0
                    });
                }

                if (input.Body != null)
                {
                    foreach (var value in input.Body.BodyParts)
                    {
                        result.WeeniePropertiesBodyPart.Add(new WeeniePropertiesBodyPart
                        {
                            Key = (ushort)value.Key,

                            DType = value.BodyPart.DType,
                            DVal  = value.BodyPart.DVal,
                            DVar  = value.BodyPart.DVar,

                            BaseArmor       = value.BodyPart.ArmorValues.BaseArmor,
                            ArmorVsSlash    = value.BodyPart.ArmorValues.ArmorVsSlash,
                            ArmorVsPierce   = value.BodyPart.ArmorValues.ArmorVsPierce,
                            ArmorVsBludgeon = value.BodyPart.ArmorValues.ArmorVsBludgeon,
                            ArmorVsCold     = value.BodyPart.ArmorValues.ArmorVsCold,
                            ArmorVsFire     = value.BodyPart.ArmorValues.ArmorVsFire,
                            ArmorVsAcid     = value.BodyPart.ArmorValues.ArmorVsAcid,
                            ArmorVsElectric = value.BodyPart.ArmorValues.ArmorVsElectric,
                            ArmorVsNether   = value.BodyPart.ArmorValues.ArmorVsNether,

                            BH = value.BodyPart.BH,

                            HLF = (float?)value.BodyPart.SD.HLF ?? 0,
                            MLF = (float?)value.BodyPart.SD.MLF ?? 0,
                            LLF = (float?)value.BodyPart.SD.LLF ?? 0,

                            HRF = (float?)value.BodyPart.SD.HRF ?? 0,
                            MRF = (float?)value.BodyPart.SD.MRF ?? 0,
                            LRF = (float?)value.BodyPart.SD.LRF ?? 0,

                            HLB = (float?)value.BodyPart.SD.HLB ?? 0,
                            MLB = (float?)value.BodyPart.SD.MLB ?? 0,
                            LLB = (float?)value.BodyPart.SD.LLB ?? 0,

                            HRB = (float?)value.BodyPart.SD.HRB ?? 0,
                            MRB = (float?)value.BodyPart.SD.MRB ?? 0,
                            LRB = (float?)value.BodyPart.SD.LRB ?? 0,
                        });
                    }
                }

                if (input.BoolStats != null)
                {
                    foreach (var value in input.BoolStats)
                    {
                        result.WeeniePropertiesBool.Add(new WeeniePropertiesBool {
                            Type = (ushort)value.Key, Value = (value.Value != 0)
                        });
                    }
                }

                if (input.CreateList != null)
                {
                    foreach (var value in input.CreateList)
                    {
                        result.WeeniePropertiesCreateList.Add(new WeeniePropertiesCreateList {
                            WeenieClassId = value.WeenieClassId ?? 0, Palette = (sbyte?)value.Palette ?? 0, Shade = (float?)value.Shade ?? 0, DestinationType = (sbyte?)value.Destination ?? 0, StackSize = value.StackSize ?? 0, TryToBond = (value.TryToBond != 0)
                        });
                    }
                }

                if (input.DidStats != null)
                {
                    foreach (var value in input.DidStats)
                    {
                        result.WeeniePropertiesDID.Add(new WeeniePropertiesDID {
                            Type = (ushort)value.Key, Value = value.Value
                        });
                    }
                }

                if (input.EmoteTable != null)
                {
                    foreach (var kvp in input.EmoteTable)
                    {
                        // kvp.key not used

                        foreach (var value in kvp.Emotes)
                        {
                            var efEmote = new WeeniePropertiesEmote
                            {
                                Category = value.Category,

                                Probability = value.Probability ?? 0,

                                WeenieClassId = value.ClassId,

                                Style    = value.Style,
                                Substyle = value.SubStyle,

                                Quest = value.Quest,

                                VendorType = (int?)value.VendorType,

                                MinHealth = value.MinHealth,
                                MaxHealth = value.MaxHealth
                            };

                            uint order = 0;

                            foreach (var action in value.Actions)
                            {
                                var efAction = new WeeniePropertiesEmoteAction
                                {
                                    Order = order, // This is an ACE specific value to maintain the correct order of EmoteActions

                                    Type   = action.EmoteActionType,
                                    Delay  = action.Delay ?? 0,
                                    Extent = action.Extent ?? 0,

                                    Motion = (int?)action.Motion,

                                    Message    = action.Message,
                                    TestString = action.TestString,

                                    Min    = (int?)action.Min,
                                    Max    = (int?)action.Max,
                                    Min64  = action.Minimum64,
                                    Max64  = action.Maximum64,
                                    MinDbl = action.FMin,
                                    MaxDbl = action.FMax,

                                    Stat    = (int?)action.Stat,
                                    Display = action.Display.HasValue ? (action.Display.Value ? 1 : 0) : (int?)null, // todo: Should we convert this to bool?

                                    Amount   = (int?)action.Amount,
                                    Amount64 = (long?)action.Amount64,
                                    HeroXP64 = (long?)action.HeroXp64,

                                    Percent = action.Percent,

                                    SpellId = (int?)action.SpellId,

                                    WealthRating  = (int?)action.WealthRating,
                                    TreasureClass = (int?)action.TreasureClass,
                                    TreasureType  = action.TreasureType,

                                    PScript = (int?)action.PScript,

                                    Sound = (int?)action.Sound
                                };

                                order++;

                                if (action.Item != null)
                                {
                                    efAction.WeenieClassId   = action.Item.WeenieClassId;
                                    efAction.Palette         = (int?)action.Item.Palette;
                                    efAction.Shade           = (float?)action.Item.Shade;
                                    efAction.DestinationType = (sbyte?)action.Item.Destination;
                                    efAction.StackSize       = action.Item.StackSize;
                                    efAction.TryToBond       = action.Item.TryToBond.HasValue ? (action.Item.TryToBond != 0) : (bool?)null;
                                }

                                if (action.Frame != null)
                                {
                                    efAction.OriginX = action.Frame.Position.X;
                                    efAction.OriginY = action.Frame.Position.Y;
                                    efAction.OriginZ = action.Frame.Position.Z;

                                    efAction.AnglesW = action.Frame.Rotations.W;
                                    efAction.AnglesX = action.Frame.Rotations.X;
                                    efAction.AnglesY = action.Frame.Rotations.Y;
                                    efAction.AnglesZ = action.Frame.Rotations.Z;
                                }

                                if (action.MPosition != null)
                                {
                                    efAction.ObjCellId = action.MPosition.LandCellId;

                                    efAction.OriginX = action.MPosition.Frame.Position.X;
                                    efAction.OriginY = action.MPosition.Frame.Position.Y;
                                    efAction.OriginZ = action.MPosition.Frame.Position.Z;

                                    efAction.AnglesW = action.MPosition.Frame.Rotations.W;
                                    efAction.AnglesX = action.MPosition.Frame.Rotations.X;
                                    efAction.AnglesY = action.MPosition.Frame.Rotations.Y;
                                    efAction.AnglesZ = action.MPosition.Frame.Rotations.Z;
                                }

                                efEmote.WeeniePropertiesEmoteAction.Add(efAction);
                            }

                            result.WeeniePropertiesEmote.Add(efEmote);
                        }
                    }
                }

                // WeeniePropertiesEventFilter

                if (input.FloatStats != null)
                {
                    foreach (var value in input.FloatStats)
                    {
                        result.WeeniePropertiesFloat.Add(new WeeniePropertiesFloat {
                            Type = (ushort)value.Key, Value = value.Value
                        });
                    }
                }

                if (input.GeneratorTable != null)
                {
                    foreach (var value in input.GeneratorTable)
                    {
                        result.WeeniePropertiesGenerator.Add(new WeeniePropertiesGenerator
                        {
                            Probability   = (float)value.Probability,
                            WeenieClassId = value.WeenieClassId,
                            Delay         = value.Delay,

                            InitCreate = (int)value.InitCreate,
                            MaxCreate  = (int)value.MaxNumber,

                            WhenCreate  = value.WhenCreate,
                            WhereCreate = value.WhereCreate,

                            StackSize = value.StackSize,

                            PaletteId = value.PaletteId,
                            Shade     = value.Shade,

                            ObjCellId = value.ObjectCell,
                            OriginX   = value.Frame.Position.X,
                            OriginY   = value.Frame.Position.Y,
                            OriginZ   = value.Frame.Position.Z,
                            AnglesW   = value.Frame.Rotations.W,
                            AnglesX   = value.Frame.Rotations.X,
                            AnglesY   = value.Frame.Rotations.Y,
                            AnglesZ   = value.Frame.Rotations.Z,

                            // Slot
                        });
                    }
                }

                if (input.IidStats != null)
                {
                    foreach (var value in input.IidStats)
                    {
                        result.WeeniePropertiesIID.Add(new WeeniePropertiesIID {
                            Type = (ushort)value.Key, Value = (uint)value.Value
                        });
                    }
                }

                if (input.IntStats != null)
                {
                    foreach (var value in input.IntStats)
                    {
                        result.WeeniePropertiesInt.Add(new WeeniePropertiesInt {
                            Type = (ushort)value.Key, Value = value.Value
                        });
                    }
                }

                if (input.Int64Stats != null)
                {
                    foreach (var value in input.Int64Stats)
                    {
                        result.WeeniePropertiesInt64.Add(new WeeniePropertiesInt64 {
                            Type = (ushort)value.Key, Value = value.Value
                        });
                    }
                }

                // WeeniePropertiesPalette

                if (input.Positions != null)
                {
                    foreach (var value in input.Positions)
                    {
                        result.WeeniePropertiesPosition.Add(new WeeniePropertiesPosition()
                        {
                            PositionType = (ushort)value.PositionType,

                            ObjCellId = value.Position.LandCellId,
                            OriginX   = value.Position.Frame.Position.X,
                            OriginY   = value.Position.Frame.Position.Y,
                            OriginZ   = value.Position.Frame.Position.Z,
                            AnglesW   = value.Position.Frame.Rotations.W,
                            AnglesX   = value.Position.Frame.Rotations.X,
                            AnglesY   = value.Position.Frame.Rotations.Y,
                            AnglesZ   = value.Position.Frame.Rotations.Z,
                        });
                    }
                }

                if (input.Skills != null)
                {
                    foreach (var value in input.Skills)
                    {
                        result.WeeniePropertiesSkill.Add(new WeeniePropertiesSkill {
                            Type = (ushort)value.SkillId, LevelFromPP = (ushort)value.Skill.LevelFromPp, SAC = (uint?)value.Skill.TrainedLevel ?? 0, PP = value.Skill.XpInvested ?? 0, InitLevel = value.Skill.Ranks ?? 0, ResistanceAtLastCheck = value.Skill.ResistanceOfLastCheck ?? 0, LastUsedTime = value.Skill.LastUsed ?? 0
                        });
                    }
                }

                if (input.Spells != null)
                {
                    foreach (var value in input.Spells)
                    {
                        result.WeeniePropertiesSpellBook.Add(new WeeniePropertiesSpellBook {
                            Spell = value.SpellId, Probability = (float?)value.Stats.CastingChance ?? 0f
                        });
                    }
                }

                if (input.StringStats != null)
                {
                    foreach (var value in input.StringStats)
                    {
                        result.WeeniePropertiesString.Add(new WeeniePropertiesString {
                            Type = (ushort)value.Key, Value = value.Value
                        });
                    }
                }

                // WeeniePropertiesTextureMap

                return(true);
            }
            catch
            {
                result = null;
                return(false);
            }
        }
        public static bool TryConvert(global::Lifestoned.DataModel.Gdle.Weenie input, out Weenie result, bool correctForEnumShift = false)
        {
            if (input.WeenieId == 0)
            {
                result = null;
                return(false);
            }

            try
            {
                result = new Weenie();

                result.ClassId = input.WeenieId;

                if (input.WeenieClassId <= ushort.MaxValue && System.Enum.IsDefined(typeof(WeenieClassId), (ushort)input.WeenieClassId))
                {
                    result.ClassName = System.Enum.GetName(typeof(WeenieClassId), (ushort)input.WeenieClassId).ToLower();
                }
                else if (input.WeenieClassId <= ushort.MaxValue && System.Enum.IsDefined(typeof(WeenieClassName), (ushort)input.WeenieClassId))
                {
                    var clsName = System.Enum.GetName(typeof(WeenieClassName), input.WeenieClassId).ToLower().Substring(2);
                    result.ClassName = clsName.Substring(0, clsName.Length - 6);
                }
                else
                {
                    result.ClassName = "ace" + input.WeenieClassId + "-" + input.Name.Replace("'", "").Replace(" ", "").Replace(".", "").Replace("(", "").Replace(")", "").Replace("+", "").Replace(":", "").Replace("_", "").Replace("-", "").Replace(",", "").ToLower();
                }

                result.Type = input.WeenieTypeId;

                if (input.Book != null)
                {
                    result.WeeniePropertiesBook                    = new WeeniePropertiesBook();
                    result.WeeniePropertiesBook.MaxNumPages        = result.WeeniePropertiesBook.MaxNumPages;
                    result.WeeniePropertiesBook.MaxNumCharsPerPage = result.WeeniePropertiesBook.MaxNumCharsPerPage;

                    if (input.Book.Pages != null)
                    {
                        result.WeeniePropertiesBookPageData = new List <WeeniePropertiesBookPageData>();

                        uint pageId = 0;

                        foreach (var value in input.Book.Pages)
                        {
                            result.WeeniePropertiesBookPageData.Add(new WeeniePropertiesBookPageData
                            {
                                PageId = pageId,

                                AuthorId      = value.AuthorId ?? 0,
                                AuthorName    = value.AuthorName,
                                AuthorAccount = value.AuthorAccount,
                                IgnoreAuthor  = value.IgnoreAuthor ?? false,
                                PageText      = value.PageText,
                            });

                            pageId++;
                        }
                    }
                }

                // LandblockInstance

                // PointsOfInterest

                // WeeniePropertiesAnimPart

                if (input.Attributes != null)
                {
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Strength, InitLevel = input.Attributes.Strength.Ranks ?? 0, LevelFromCP = input.Attributes.Strength.LevelFromCp, CPSpent = input.Attributes.Strength.XpSpent ?? 0
                    });
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Endurance, InitLevel = input.Attributes.Endurance.Ranks ?? 0, LevelFromCP = input.Attributes.Endurance.LevelFromCp, CPSpent = input.Attributes.Endurance.XpSpent ?? 0
                    });
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Quickness, InitLevel = input.Attributes.Quickness.Ranks ?? 0, LevelFromCP = input.Attributes.Quickness.LevelFromCp, CPSpent = input.Attributes.Quickness.XpSpent ?? 0
                    });
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Coordination, InitLevel = input.Attributes.Coordination.Ranks ?? 0, LevelFromCP = input.Attributes.Coordination.LevelFromCp, CPSpent = input.Attributes.Coordination.XpSpent ?? 0
                    });
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Focus, InitLevel = input.Attributes.Focus.Ranks ?? 0, LevelFromCP = input.Attributes.Focus.LevelFromCp, CPSpent = input.Attributes.Focus.XpSpent ?? 0
                    });
                    result.WeeniePropertiesAttribute.Add(new WeeniePropertiesAttribute {
                        Type = (ushort)PropertyAttribute.Self, InitLevel = input.Attributes.Self.Ranks ?? 0, LevelFromCP = input.Attributes.Self.LevelFromCp, CPSpent = input.Attributes.Self.XpSpent ?? 0
                    });

                    result.WeeniePropertiesAttribute2nd.Add(new WeeniePropertiesAttribute2nd {
                        Type = (ushort)PropertyAttribute2nd.MaxHealth, InitLevel = input.Attributes.Health.Ranks ?? 0, LevelFromCP = input.Attributes.Health.LevelFromCp ?? 0, CPSpent = input.Attributes.Health.XpSpent ?? 0, CurrentLevel = input.Attributes.Health.Current ?? 0
                    });
                    result.WeeniePropertiesAttribute2nd.Add(new WeeniePropertiesAttribute2nd {
                        Type = (ushort)PropertyAttribute2nd.MaxStamina, InitLevel = input.Attributes.Stamina.Ranks ?? 0, LevelFromCP = input.Attributes.Stamina.LevelFromCp ?? 0, CPSpent = input.Attributes.Stamina.XpSpent ?? 0, CurrentLevel = input.Attributes.Stamina.Current ?? 0
                    });
                    result.WeeniePropertiesAttribute2nd.Add(new WeeniePropertiesAttribute2nd {
                        Type = (ushort)PropertyAttribute2nd.MaxMana, InitLevel = input.Attributes.Mana.Ranks ?? 0, LevelFromCP = input.Attributes.Mana.LevelFromCp ?? 0, CPSpent = input.Attributes.Mana.XpSpent ?? 0, CurrentLevel = input.Attributes.Mana.Current ?? 0
                    });
                }

                if (input.Body != null)
                {
                    foreach (var value in input.Body.BodyParts)
                    {
                        result.WeeniePropertiesBodyPart.Add(new WeeniePropertiesBodyPart
                        {
                            Key = (ushort)value.Key,

                            DType = value.BodyPart.DType,
                            DVal  = value.BodyPart.DVal,
                            DVar  = value.BodyPart.DVar,

                            BaseArmor       = value.BodyPart.ArmorValues.BaseArmor,
                            ArmorVsSlash    = value.BodyPart.ArmorValues.ArmorVsSlash,
                            ArmorVsPierce   = value.BodyPart.ArmorValues.ArmorVsPierce,
                            ArmorVsBludgeon = value.BodyPart.ArmorValues.ArmorVsBludgeon,
                            ArmorVsCold     = value.BodyPart.ArmorValues.ArmorVsCold,
                            ArmorVsFire     = value.BodyPart.ArmorValues.ArmorVsFire,
                            ArmorVsAcid     = value.BodyPart.ArmorValues.ArmorVsAcid,
                            ArmorVsElectric = value.BodyPart.ArmorValues.ArmorVsElectric,
                            ArmorVsNether   = value.BodyPart.ArmorValues.ArmorVsNether,

                            BH = value.BodyPart.BH,

                            HLF = (float?)value.BodyPart.SD.HLF ?? 0,
                            MLF = (float?)value.BodyPart.SD.MLF ?? 0,
                            LLF = (float?)value.BodyPart.SD.LLF ?? 0,

                            HRF = (float?)value.BodyPart.SD.HRF ?? 0,
                            MRF = (float?)value.BodyPart.SD.MRF ?? 0,
                            LRF = (float?)value.BodyPart.SD.LRF ?? 0,

                            HLB = (float?)value.BodyPart.SD.HLB ?? 0,
                            MLB = (float?)value.BodyPart.SD.MLB ?? 0,
                            LLB = (float?)value.BodyPart.SD.LLB ?? 0,

                            HRB = (float?)value.BodyPart.SD.HRB ?? 0,
                            MRB = (float?)value.BodyPart.SD.MRB ?? 0,
                            LRB = (float?)value.BodyPart.SD.LRB ?? 0,
                        });
                    }
                }

                if (input.BoolStats != null)
                {
                    foreach (var value in input.BoolStats)
                    {
                        if (result.WeeniePropertiesBool.FirstOrDefault(x => x.Type == (ushort)value.Key) == null)
                        {
                            result.WeeniePropertiesBool.Add(new WeeniePropertiesBool {
                                Type = (ushort)value.Key, Value = (value.Value != 0)
                            });
                        }
                    }
                }

                if (input.CreateList != null)
                {
                    foreach (var value in input.CreateList)
                    {
                        result.WeeniePropertiesCreateList.Add(new WeeniePropertiesCreateList {
                            WeenieClassId = value.WeenieClassId ?? 0, Palette = (sbyte?)value.Palette ?? 0, Shade = (float?)value.Shade ?? 0, DestinationType = (sbyte?)value.Destination ?? 0, StackSize = value.StackSize ?? 0, TryToBond = (value.TryToBond != 0)
                        });
                    }
                }

                if (input.DidStats != null)
                {
                    foreach (var value in input.DidStats)
                    {
                        if (!correctForEnumShift)
                        {
                            result.WeeniePropertiesDID.Add(new WeeniePropertiesDID {
                                Type = (ushort)value.Key, Value = value.Value
                            });
                        }
                        else
                        {
                            var valCorrected = value.Value;

                            // Fix PhysicsScript ENUM shift post 16PY data
                            if (value.Key == (int)PropertyDataId.PhysicsScript)
                            {
                                // These are the only ones in 16PY database, not entirely certain where the shift started but the change below is correct for end of retail enum
                                if (valCorrected >= 83 && valCorrected <= 89)
                                {
                                    valCorrected++;
                                }
                            }

                            // Fix PhysicsScript ENUM shift post 16PY data
                            if (value.Key == (int)PropertyDataId.RestrictionEffect)
                            {
                                if (valCorrected >= 83)
                                {
                                    valCorrected++;
                                }
                            }

                            if (result.WeeniePropertiesDID.FirstOrDefault(x => x.Type == (ushort)value.Key) == null)
                            {
                                result.WeeniePropertiesDID.Add(new WeeniePropertiesDID {
                                    Type = (ushort)value.Key, Value = valCorrected
                                });
                            }
                        }
                    }
                }

                if (input.EmoteTable != null)
                {
                    foreach (var kvp in input.EmoteTable)
                    {
                        // kvp.key not used

                        foreach (var value in kvp.Emotes)
                        {
                            var efEmote = new WeeniePropertiesEmote
                            {
                                Category = value.Category,

                                Probability = value.Probability ?? 0,

                                WeenieClassId = value.ClassId,

                                Style    = value.Style,
                                Substyle = value.SubStyle,

                                Quest = value.Quest,

                                VendorType = (int?)value.VendorType,

                                MinHealth = value.MinHealth,
                                MaxHealth = value.MaxHealth
                            };

                            // Fix MotionCommand ENUM shift post 16PY data
                            if (correctForEnumShift && efEmote.Style.HasValue)
                            {
                                var oldStyle = (ACE.Entity.Enum.MotionCommand)efEmote.Style;
                                var index    = efEmote.Style.Value & 0xFFFF;
                                if (index >= 0x115)
                                {
                                    var newStyle = (ACE.Entity.Enum.MotionCommand)efEmote.Style + 3;
                                    efEmote.Style += 3;
                                }
                            }
                            if (correctForEnumShift && efEmote.Substyle.HasValue)
                            {
                                var oldSubstyle = (ACE.Entity.Enum.MotionCommand)efEmote.Substyle;
                                var index       = efEmote.Substyle.Value & 0xFFFF;
                                if (index >= 0x115)
                                {
                                    var newSubstyle = (ACE.Entity.Enum.MotionCommand)efEmote.Substyle + 3;
                                    efEmote.Substyle += 3;
                                }
                            }

                            uint order = 0;

                            foreach (var action in value.Actions)
                            {
                                var efAction = new WeeniePropertiesEmoteAction
                                {
                                    Order = order, // This is an ACE specific value to maintain the correct order of EmoteActions

                                    Type   = action.EmoteActionType,
                                    Delay  = action.Delay ?? 0,
                                    Extent = action.Extent ?? 0,

                                    Motion = (int?)action.Motion,

                                    Message    = action.Message,
                                    TestString = action.TestString,

                                    Min    = (int?)action.Min,
                                    Max    = (int?)action.Max,
                                    Min64  = action.Minimum64,
                                    Max64  = action.Maximum64,
                                    MinDbl = action.FMin,
                                    MaxDbl = action.FMax,

                                    Stat    = (int?)action.Stat,
                                    Display = action.Display,

                                    Amount   = (int?)action.Amount,
                                    Amount64 = (long?)action.Amount64,
                                    HeroXP64 = (long?)action.HeroXp64,

                                    Percent = action.Percent,

                                    SpellId = (int?)action.SpellId,

                                    WealthRating  = (int?)action.WealthRating,
                                    TreasureClass = (int?)action.TreasureClass,
                                    TreasureType  = action.TreasureType,

                                    PScript = (int?)action.PScript,

                                    Sound = (int?)action.Sound
                                };

                                // Fix MotionCommand ENUM shift post 16PY data
                                if (correctForEnumShift && efAction.Motion.HasValue)
                                {
                                    var oldMotion = (ACE.Entity.Enum.MotionCommand)efAction.Motion;
                                    var index     = efAction.Motion.Value & 0xFFFF;
                                    if (index >= 0x115)
                                    {
                                        var newMotion = (ACE.Entity.Enum.MotionCommand)efAction.Motion + 3;
                                        efAction.Motion += 3;
                                    }
                                }

                                // Fix PhysicsScript ENUM shift post 16PY data
                                if (correctForEnumShift && efAction.PScript.HasValue)
                                {
                                    if (efAction.PScript.Value >= 83)
                                    {
                                        efAction.PScript++;
                                    }
                                }

                                order++;

                                if (action.Item != null)
                                {
                                    efAction.WeenieClassId   = action.Item.WeenieClassId;
                                    efAction.Palette         = (int?)action.Item.Palette;
                                    efAction.Shade           = (float?)action.Item.Shade;
                                    efAction.DestinationType = (sbyte?)action.Item.Destination;
                                    efAction.StackSize       = action.Item.StackSize;
                                    efAction.TryToBond       = action.Item.TryToBond.HasValue ? (action.Item.TryToBond != 0) : (bool?)null;
                                }

                                if (action.Frame != null)
                                {
                                    efAction.OriginX = action.Frame.Position.X;
                                    efAction.OriginY = action.Frame.Position.Y;
                                    efAction.OriginZ = action.Frame.Position.Z;

                                    efAction.AnglesW = action.Frame.Rotations.W;
                                    efAction.AnglesX = action.Frame.Rotations.X;
                                    efAction.AnglesY = action.Frame.Rotations.Y;
                                    efAction.AnglesZ = action.Frame.Rotations.Z;
                                }

                                if (action.MPosition != null)
                                {
                                    efAction.ObjCellId = action.MPosition.LandCellId;

                                    efAction.OriginX = action.MPosition.Frame.Position.X;
                                    efAction.OriginY = action.MPosition.Frame.Position.Y;
                                    efAction.OriginZ = action.MPosition.Frame.Position.Z;

                                    efAction.AnglesW = action.MPosition.Frame.Rotations.W;
                                    efAction.AnglesX = action.MPosition.Frame.Rotations.X;
                                    efAction.AnglesY = action.MPosition.Frame.Rotations.Y;
                                    efAction.AnglesZ = action.MPosition.Frame.Rotations.Z;
                                }

                                efEmote.WeeniePropertiesEmoteAction.Add(efAction);
                            }

                            result.WeeniePropertiesEmote.Add(efEmote);
                        }
                    }
                }

                // WeeniePropertiesEventFilter

                if (input.FloatStats != null)
                {
                    foreach (var value in input.FloatStats)
                    {
                        if (result.WeeniePropertiesFloat.FirstOrDefault(x => x.Type == (ushort)value.Key) == null)
                        {
                            result.WeeniePropertiesFloat.Add(new WeeniePropertiesFloat {
                                Type = (ushort)value.Key, Value = value.Value
                            });
                        }
                    }
                }

                if (input.GeneratorTable != null)
                {
                    foreach (var value in input.GeneratorTable)
                    {
                        result.WeeniePropertiesGenerator.Add(new WeeniePropertiesGenerator
                        {
                            Probability   = (float)value.Probability,
                            WeenieClassId = value.WeenieClassId,
                            Delay         = value.Delay,

                            InitCreate = (int)value.InitCreate,
                            MaxCreate  = (int)value.MaxNumber,

                            WhenCreate  = value.WhenCreate,
                            WhereCreate = value.WhereCreate,

                            StackSize = value.StackSize,

                            PaletteId = value.PaletteId,
                            Shade     = value.Shade,

                            ObjCellId = value.ObjectCell,
                            OriginX   = value.Frame.Position.X,
                            OriginY   = value.Frame.Position.Y,
                            OriginZ   = value.Frame.Position.Z,
                            AnglesW   = value.Frame.Rotations.W,
                            AnglesX   = value.Frame.Rotations.X,
                            AnglesY   = value.Frame.Rotations.Y,
                            AnglesZ   = value.Frame.Rotations.Z,

                            // Slot
                        });
                    }
                }

                if (input.IidStats != null)
                {
                    foreach (var value in input.IidStats)
                    {
                        if (result.WeeniePropertiesIID.FirstOrDefault(x => x.Type == (ushort)value.Key) == null)
                        {
                            result.WeeniePropertiesIID.Add(new WeeniePropertiesIID {
                                Type = (ushort)value.Key, Value = (uint)value.Value
                            });
                        }
                    }
                }

                if (input.IntStats != null)
                {
                    foreach (var value in input.IntStats)
                    {
                        if (result.WeeniePropertiesInt.FirstOrDefault(x => x.Type == (ushort)value.Key) == null)
                        {
                            result.WeeniePropertiesInt.Add(new WeeniePropertiesInt {
                                Type = (ushort)value.Key, Value = value.Value
                            });
                        }
                    }
                }

                if (input.Int64Stats != null)
                {
                    foreach (var value in input.Int64Stats)
                    {
                        if (result.WeeniePropertiesInt64.FirstOrDefault(x => x.Type == (ushort)value.Key) == null)
                        {
                            result.WeeniePropertiesInt64.Add(new WeeniePropertiesInt64 {
                                Type = (ushort)value.Key, Value = value.Value
                            });
                        }
                    }
                }

                // WeeniePropertiesPalette

                if (input.Positions != null)
                {
                    foreach (var value in input.Positions)
                    {
                        if (result.WeeniePropertiesPosition.FirstOrDefault(x => x.PositionType == (ushort)value.PositionType) == null)
                        {
                            result.WeeniePropertiesPosition.Add(new WeeniePropertiesPosition()
                            {
                                PositionType = (ushort)value.PositionType,

                                ObjCellId = value.Position.LandCellId,
                                OriginX   = value.Position.Frame.Position.X,
                                OriginY   = value.Position.Frame.Position.Y,
                                OriginZ   = value.Position.Frame.Position.Z,
                                AnglesW   = value.Position.Frame.Rotations.W,
                                AnglesX   = value.Position.Frame.Rotations.X,
                                AnglesY   = value.Position.Frame.Rotations.Y,
                                AnglesZ   = value.Position.Frame.Rotations.Z,
                            });
                        }
                    }
                }

                if (input.Skills != null)
                {
                    foreach (var value in input.Skills)
                    {
                        if (result.WeeniePropertiesSkill.FirstOrDefault(x => x.Type == (ushort)value.SkillId) == null)
                        {
                            result.WeeniePropertiesSkill.Add(new WeeniePropertiesSkill {
                                Type = (ushort)value.SkillId, LevelFromPP = (ushort)value.Skill.LevelFromPp, SAC = (uint?)value.Skill.TrainedLevel ?? 0, PP = value.Skill.XpInvested ?? 0, InitLevel = value.Skill.Ranks ?? 0, ResistanceAtLastCheck = value.Skill.ResistanceOfLastCheck ?? 0, LastUsedTime = value.Skill.LastUsed ?? 0
                            });
                        }
                    }
                }

                if (input.Spells != null)
                {
                    foreach (var value in input.Spells)
                    {
                        if (result.WeeniePropertiesDID.FirstOrDefault(x => x.Type == (int)PropertyDataId.Spell && x.Value == value.SpellId) == null)
                        {
                            result.WeeniePropertiesSpellBook.Add(new WeeniePropertiesSpellBook {
                                Spell = value.SpellId, Probability = (float?)value.Stats.CastingChance ?? 0f
                            });
                        }
                    }
                }

                if (input.StringStats != null)
                {
                    foreach (var value in input.StringStats)
                    {
                        if (result.WeeniePropertiesString.FirstOrDefault(x => x.Type == (ushort)value.Key) == null)
                        {
                            result.WeeniePropertiesString.Add(new WeeniePropertiesString {
                                Type = (ushort)value.Key, Value = value.Value
                            });
                        }
                    }
                }

                // WeeniePropertiesTextureMap

                return(true);
            }
            catch
            {
                result = null;
                return(false);
            }
        }