Exemplo n.º 1
0
        public static Models.AdvancedClass Load(GomObject obj)
        {
            Models.AdvancedClass ac = new Models.AdvancedClass();
            ac.NodeId   = obj.Id;
            ac.Fqn      = obj.Name;
            ac.NameId   = obj.Data.ValueOrDefault <long>("chrAdvancedClassDataNameId", 0);
            ac.Id       = (int)ac.NameId;
            ac.Name     = classNames.GetText(StringOffset + ac.NameId, ac.Fqn);
            ac.Packages = new List <Models.AbilityPackage>();
            ulong classSpecNodeId = obj.Data.ValueOrDefault <ulong>("chrAdvancedClassDataClassSpec", 0);

            ac.ClassSpec = ClassSpecLoader.Load(classSpecNodeId);
            return(ac);
        }
Exemplo n.º 2
0
        private static void LoadRequiredClasses(Quest qst, GomObject obj)
        {
            qst.Classes = new List <ClassSpec>();
            var reqClasses = (Dictionary <object, object>)obj.Data.ValueOrDefault <Dictionary <object, object> >("qstReqClasses", null);

            if (reqClasses != null)
            {
                foreach (var kvp in reqClasses)
                {
                    var spec    = ClassSpecLoader.Load((ulong)kvp.Key);
                    var enabled = (bool)kvp.Value;
                    if (enabled)
                    {
                        qst.Classes.Add(spec);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static Item Load(Models.GameObject obj, GomObject gom)
        {
            var itm = (Models.Item)obj;

            itm.NodeId          = gom.Id;
            itm.Fqn             = gom.Name;
            itm.AppearanceColor = Models.AppearanceColorExtensions.ToAppearanceColor((string)gom.Data.ValueOrDefault <string>("itmEnhancementColor", null));
            itm.ArmorSpec       = Models.ArmorSpecExtensions.ToArmorSpec((long)gom.Data.ValueOrDefault <long>("itmArmorSpec", 0));
            itm.Binding         = Models.ItemBindingRuleExtensions.ToBindingRule((ScriptEnum)gom.Data.ValueOrDefault <ScriptEnum>("itmBindingRule", null));

            itm.CombinedStatModifiers = new ItemStatList();
            itm.ConsumedOnUse         = (bool)gom.Data.ValueOrDefault <bool>("itmConsumedOnUse", false);
            //itm.Conversation
            itm.ConversationFqn = gom.Data.ValueOrDefault <string>("itmConversation", null);

            var descLookup = (GomObjectData)(gom.Data.Get <Dictionary <object, object> >("locTextRetrieverMap")[DescLookupKey]);

            itm.DescriptionId = descLookup.Get <long>("strLocalizedTextRetrieverStringID");
            itm.Description   = StringTable.TryGetString(itm.Fqn, descLookup);

            itm.DisassembleCategory    = Models.ProfessionSubtypeExtensions.ToProfessionSubtype((ScriptEnum)gom.Data.ValueOrDefault <ScriptEnum>("prfDisassembleCategory", null));
            itm.Durability             = (int)gom.Data.ValueOrDefault <long>("itmMaxDurability", 0);
            itm.EnhancementCategory    = Models.EnhancementCategoryExtensions.ToEnhancementCategory((ScriptEnum)gom.Data.ValueOrDefault <ScriptEnum>("itmEnhancementCategory", null));
            itm.EnhancementSubCategory = Models.EnhancementSubCategoryExtensions.ToEnhancementSubCategory((ScriptEnum)gom.Data.ValueOrDefault <ScriptEnum>("itmEnhancementSubCategory", null));
            itm.EnhancementType        = Models.EnhancementTypeExtensions.ToEnhancementType((long)gom.Data.ValueOrDefault <long>("itmEnhancementType", 0));

            // Enhancement Slots
            itm.EnhancementSlots = new ItemEnhancementList();
            var enhancementSlots    = (List <object>)gom.Data.ValueOrDefault <List <object> >("itmEnhancementSlots", null);
            var enhancementDefaults = (List <object>)gom.Data.ValueOrDefault <List <object> >("itmEnhancementDefaults", null);

            if (enhancementSlots != null)
            {
                for (var i = 0; i < 5; i++)
                {
                    long slot = (long)enhancementSlots[i];
                    if (slot == 0)
                    {
                        continue;
                    }

                    ItemEnhancement enh = new ItemEnhancement();
                    enh.Slot           = EnhancementTypeExtensions.ToEnhancementType(slot);
                    enh.ModificationId = (ulong)enhancementDefaults[i];
                    if (enh.ModificationId != 0)
                    {
                        enh.Modification = ItemLoader.Load(enh.ModificationId);
                    }

                    // Don't add empty modulator/augment slots to gear since for some reason it seems to be on every damn modifiable item
                    if ((enh.Slot == EnhancementType.Modulator) && (enh.Modification == null))
                    {
                        continue;
                    }

                    itm.EnhancementSlots.Add(enh);
                }
            }

            itm.EquipAbilityId = gom.Data.ValueOrDefault <ulong>("itmEquipAbility", 0);
            itm.EquipAbility   = AbilityLoader.Load(itm.EquipAbilityId);

            itm.GiftRank = Models.GiftRankExtensions.ToGiftRank((ScriptEnum)gom.Data.ValueOrDefault <ScriptEnum>("itmGiftAffectionRank", null));
            itm.GiftType = Models.GiftTypeExtensions.ToGiftType((ScriptEnum)gom.Data.ValueOrDefault <ScriptEnum>("itmGiftType", null));
            itm.Icon     = gom.Data.ValueOrDefault <string>("itmIcon", String.Empty);
            TorLib.Icons.Add(itm.Icon);

            itm.ItemLevel    = (int)gom.Data.ValueOrDefault <long>("itmBaseLevel", 0);
            itm.MaxStack     = (int)gom.Data.ValueOrDefault <long>("itmStackMax", 0);
            itm.ModifierSpec = gom.Data.ValueOrDefault <long>("itmModifierSetID", 0);
            itm.MountSpec    = gom.Data.ValueOrDefault <long>("itmMountSpec", 0);

            var nameLookup = (GomObjectData)(gom.Data.Get <Dictionary <object, object> >("locTextRetrieverMap")[NameLookupKey]);

            itm.NameId = nameLookup.Get <long>("strLocalizedTextRetrieverStringID");
            itm.Name   = StringTable.TryGetString(itm.Fqn, nameLookup);
            if (itm.Name == null)
            {
                itm.Name = String.Empty;
            }
            itm.Id = (ulong)(itm.NameId >> 32);

            itm.Quality = Models.ItemQualityExtensions.ToItemQuality((ScriptEnum)gom.Data.ValueOrDefault <ScriptEnum>("itmBaseQuality", null));
            //if (itm.EnhancementType != EnhancementType.None)
            //{
            itm.Rating = Tables.ItemRating.GetRating(itm.ItemLevel, itm.Quality);
            //}
            //else
            //{
            //itm.Rating = Tables.ItemRating.GetRating(itm.ItemLevel, ItemQuality.Premium);
            //}
            itm.RequiresAlignment         = (bool)gom.Data.ValueOrDefault <bool>("itmAlignmentRequired", false);
            itm.RequiredAlignmentTier     = (int)gom.Data.ValueOrDefault <long>("itmRequiredAlignmentTier", int.MaxValue);
            itm.RequiredAlignmentInverted = (bool)gom.Data.ValueOrDefault <bool>("itmRequiredAlignmentInverted", false);

            itm.Field_4000000FAFE42471 = gom.Data.ValueOrDefault <long>("field_4000000FAFE42471", 0);

            // Required Classes
            itm.RequiredClasses = new ClassSpecList();
            var classMap = (Dictionary <object, object>)gom.Data.ValueOrDefault <Dictionary <object, object> >("itmRequiredClasses", null);

            if (classMap != null)
            {
                foreach (var kvp in classMap)
                {
                    if ((bool)kvp.Value)
                    {
                        var classSpec = ClassSpecLoader.Load((ulong)kvp.Key);
                        if (classSpec == null)
                        {
                            continue;
                        }
                        itm.RequiredClasses.Add(classSpec);
                    }
                }
            }

            itm.RequiredGender          = GenderExtensions.ToGender((ScriptEnum)gom.Data.ValueOrDefault <ScriptEnum>("itmGenderRequired", null));
            itm.RequiredLevel           = (int)gom.Data.ValueOrDefault <long>("itmMinimumLevel", 0);
            itm.RequiredProfession      = Models.ProfessionExtensions.ToProfession((ScriptEnum)gom.Data.ValueOrDefault <ScriptEnum>("prfProfessionRequired", null));
            itm.RequiredProfessionLevel = (int)gom.Data.ValueOrDefault <long>("prfProfessionLevelRequired", 0);
            itm.RequiresSocial          = (bool)gom.Data.ValueOrDefault <bool>("itmSocialScoreRequired", false);
            itm.RequiredSocialTier      = (int)gom.Data.ValueOrDefault <long>("itmRequiredSocialScoreTier", 0);
            itm.RequiredValorRank       = (int)gom.Data.ValueOrDefault <long>("itmRequiredValorRank", 0);

            // Item is a recipe/schematic
            GomObjectData schematic = (GomObjectData)gom.Data.ValueOrDefault <object>("prfLearnedSchematic", null);

            if (schematic != null)
            {
                itm.SchematicId = schematic.Get <ulong>("prfSchematicSpecId");
                itm.Schematic   = SchematicLoader.Load(itm.SchematicId);
            }

            itm.ShieldSpec = ArmorSpecExtensions.ToArmorSpec((long)gom.Data.ValueOrDefault <long>("itmShieldSpec", 0));

            // Valid Inventory Slots
            itm.Slots = new SlotTypeList();
            var slotList = (List <object>)gom.Data.ValueOrDefault <List <object> >("itmSlotTypes", null);

            if (slotList != null)
            {
                foreach (var slot in slotList)
                {
                    SlotType slotType = SlotTypeExtensions.ToSlotType((ScriptEnum)slot);
                    if (SlotTypeExtensions.IgnoreSlot(slotType))
                    {
                        continue;
                    }
                    itm.Slots.Add(slotType);
                }
            }

            // Item Stats
            var stats = (Dictionary <object, object>)gom.Data.ValueOrDefault <Dictionary <object, object> >("itmEquipModStats", null);

            itm.StatModifiers = new ItemStatList();
            if (stats != null)
            {
                foreach (var kvp in stats)
                {
                    ItemStat itmStat = new ItemStat();
                    itmStat.Stat     = StatExtensions.ToStat((ScriptEnum)kvp.Key);
                    itmStat.Modifier = (int)(float)kvp.Value;
                    itm.StatModifiers.Add(itmStat);
                }
            }

            // Combined Stats
            itm.CombinedStatModifiers = new ItemStatList();
            itm.CombinedRequiredLevel = itm.RequiredLevel;
            itm.CombinedRating        = itm.Rating;
            foreach (var stat in itm.StatModifiers)
            {
                var itmStat = new ItemStat();
                itmStat.Stat     = stat.Stat;
                itmStat.Modifier = stat.Modifier;
                itm.CombinedStatModifiers.Add(itmStat);
            }

            foreach (var mod in itm.EnhancementSlots)
            {
                if (mod.Modification != null)
                {
                    if (mod.Slot.IsBaseMod())
                    {
                        if (mod.Modification.RequiredLevel > itm.CombinedRequiredLevel)
                        {
                            itm.CombinedRequiredLevel = mod.Modification.RequiredLevel;
                        }
                        if (mod.Modification.Rating > itm.CombinedRating)
                        {
                            itm.CombinedRating = mod.Modification.Rating;
                        }
                    }

                    foreach (var stat in mod.Modification.CombinedStatModifiers)
                    {
                        ItemStat itmStat = itm.CombinedStatModifiers.FirstOrDefault(s => s.Stat == stat.Stat);
                        if (itmStat == null)
                        {
                            itmStat           = new ItemStat();
                            itmStat.Stat      = stat.Stat;
                            itmStat.Modifier += stat.Modifier;
                            itm.CombinedStatModifiers.Add(itmStat);
                        }
                        else
                        {
                            itmStat.Modifier += stat.Modifier;
                        }
                    }
                }
            }

            //itm.TreasurePackageSpec;
            itm.TreasurePackageId = (long)gom.Data.ValueOrDefault <long>("field_40000013407C89A3", 0);
            itm.TypeBitSet        = (int)(long)gom.Data.ValueOrDefault <long>("itmTypeBitSet", 0);
            itm.UniqueLimit       = (int)gom.Data.ValueOrDefault <long>("itmUniqueLimit", 0);

            itm.UseAbilityId = gom.Data.ValueOrDefault <ulong>("itmUsageAbility", 0);
            itm.UseAbility   = AbilityLoader.Load(itm.UseAbilityId);

            itm.Value           = (int)gom.Data.ValueOrDefault <long>("itmValue", 0);
            itm.VendorStackSize = (int)gom.Data.ValueOrDefault <long>("itmStackVendor", 0);
            itm.WeaponSpec      = WeaponSpecExtensions.ToWeaponSpec((ulong)gom.Data.ValueOrDefault <ulong>("cbtWeaponSpec", 0));

            //ulong dmgType = (ulong)gom.Data.ValueOrDefault<ulong>("cbtDamageType", 0);
            //itm.DamageType = ItemDamageTypeExtensions.ToItemDamageType(dmgType);
            switch (itm.WeaponSpec)
            {
            case WeaponSpec.Lightsaber:
            case WeaponSpec.Polesaber:
            case WeaponSpec.Pistol:
            case WeaponSpec.Rifle:
            case WeaponSpec.SniperRifle:
            case WeaponSpec.AssaultCannon:
            { itm.DamageType = ItemDamageType.Energy; break; }

            case WeaponSpec.Vibroblade:
            case WeaponSpec.VibrobladeTech:
            case WeaponSpec.Vibroknife:
            case WeaponSpec.Shotgun:
            case WeaponSpec.Electrostaff:
            case WeaponSpec.ElectrostaffTech:
            { itm.DamageType = ItemDamageType.Kinetic; break; }

            default:
            { itm.DamageType = ItemDamageType.None; break; }
            }

            itm.IsModdable = ((itm.Quality == ItemQuality.Prototype) && (itm.EnhancementSlots.Count > 1)) || itm.Quality == ItemQuality.Moddable;

            ItemSubCategoryExtensions.SetCategory(itm);

            return(itm);
        }
Exemplo n.º 4
0
        public static Models.Npc Load(Models.Npc npc, GomObject obj)
        {
            if (obj == null)
            {
                return(npc);
            }
            if (npc == null)
            {
                return(null);
            }

            ulong baseNpcId = obj.Data.ValueOrDefault <ulong>("npcParentSpecId", 0);
            Npc   baseNpc;

            if (baseNpcId > 0)
            {
                baseNpc = Load(baseNpcId);
            }
            else
            {
                baseNpc = new Npc();
            }

            npc.Fqn    = obj.Name;
            npc.NodeId = obj.Id;

            var           textLookup     = obj.Data.ValueOrDefault <Dictionary <object, object> >("locTextRetrieverMap", null);
            GomObjectData nameLookupData = (GomObjectData)textLookup[NameLookupKey];
            var           nameId         = nameLookupData.ValueOrDefault <long>("strLocalizedTextRetrieverStringID", 0);

            npc.Name = StringTable.TryGetString(npc.Fqn, nameLookupData);

            if (textLookup.ContainsKey(TitleLookupKey))
            {
                var titleLookupData = (GomObjectData)textLookup[TitleLookupKey];
                npc.Title = StringTable.TryGetString(npc.Fqn, titleLookupData);
            }

            npc.Id = (ulong)(nameId >> 32);

            //if (objIdMap.ContainsKey(npc.Id))
            //{
            //    Npc otherNpc = objIdMap[npc.Id];
            //    if (!String.Equals(otherNpc.Fqn, npc.Fqn))
            //    {
            //        throw new InvalidOperationException(String.Format("Duplicate NPC Ids: {0} and {1}", otherNpc.Fqn, npc.Fqn));
            //    }
            //}
            //else
            //{
            //    objIdMap[npc.Id] = npc;
            //}

            npc.MinLevel = (int)obj.Data.ValueOrDefault <long>("field_4000000027BDA14B", (long)baseNpc.MinLevel);
            npc.MaxLevel = (int)obj.Data.ValueOrDefault <long>("field_4000000027BDA14C", (long)baseNpc.MaxLevel);

            // Load Toughness
            var toughnessEnum = (ScriptEnum)obj.Data.ValueOrDefault <ScriptEnum>("field_40000005618EC27C", null);

            if (toughnessEnum == null)
            {
                npc.Toughness = baseNpc.Toughness;
            }
            else
            {
                npc.Toughness = ToughnessExtensions.ToToughness(toughnessEnum);
            }

            // Load Faction
            long factionId = obj.Data.ValueOrDefault <long>("npcFaction", 0);

            if (factionId == 0)
            {
                npc.Faction = baseNpc.Faction;
            }
            else
            {
                npc.Faction = FactionExtensions.ToFaction(factionId);
            }

            npc.DifficultyFlags = (int)obj.Data.ValueOrDefault <long>("spnDifficultyLevelFlags", baseNpc.DifficultyFlags);

            npc.LootTableId = obj.Data.ValueOrDefault <long>("field_40000009AF9F1222", baseNpc.LootTableId);

            ulong npcClass = obj.Data.ValueOrDefault <ulong>("npcClassPackage", 0);

            if (npcClass == 0)
            {
                npc.ClassSpec = baseNpc.ClassSpec;
            }
            else
            {
                npc.ClassSpec = ClassSpecLoader.Load(npcClass);
            }

            ulong cdxNodeId = obj.Data.ValueOrDefault <ulong>("npcCodexSpec", 0);

            if (cdxNodeId > 0)
            {
                npc.Codex = CodexLoader.Load(cdxNodeId);
            }
            else
            {
                npc.Codex = baseNpc.Codex;
            }

            var profTrained = (ScriptEnum)obj.Data.ValueOrDefault <ScriptEnum>("prfTrainerProfession", null);

            if (profTrained == null)
            {
                npc.ProfessionTrained = baseNpc.ProfessionTrained;
            }
            else
            {
                npc.ProfessionTrained = ProfessionExtensions.ToProfession(profTrained);
            }

            List <object> trainedPackages = obj.Data.ValueOrDefault <List <object> >("field_4000000A1D72EA38", null);

            if (trainedPackages == null)
            {
                npc.IsClassTrainer = baseNpc.IsClassTrainer;
            }
            else
            {
                npc.IsClassTrainer = trainedPackages.Count > 0;
            }

            npc.ConversationFqn = obj.Data.ValueOrDefault <string>("cnvConversationName", baseNpc.ConversationFqn);

            List <object> vendorPackages = obj.Data.ValueOrDefault <List <object> >("field_400000037C4DE713", null);

            if (vendorPackages != null)
            {
                foreach (string pkg in vendorPackages)
                {
                    npc.VendorPackages.Add(pkg.ToLower());
                }
            }
            else
            {
                npc.VendorPackages = baseNpc.VendorPackages;
            }

            return(npc);
        }
Exemplo n.º 5
0
        public static Models.Codex Load(Models.Codex cdx, GomObject obj)
        {
            if (obj == null)
            {
                return(null);
            }
            if (cdx == null)
            {
                return(null);
            }

            cdx.Fqn    = obj.Name;
            cdx.NodeId = obj.Id;

            cdx.Image = obj.Data.ValueOrDefault <string>("cdxImage", null);

            TorLib.Icons.AddCodex(cdx.Image);

            var    textLookup  = obj.Data.ValueOrDefault <Dictionary <object, object> >("locTextRetrieverMap", null);
            var    descLookup  = (GomObjectData)textLookup[DescriptionLookupKey];
            var    titleLookup = (GomObjectData)textLookup[NameLookupKey];
            object categoryLookup;

            if (textLookup.TryGetValue(CategoryLookupKey, out categoryLookup))
            {
                cdx.CategoryId = ((GomObjectData)categoryLookup).ValueOrDefault <long>("strLocalizedTextRetrieverStringID", 0);
            }

            var titleId = titleLookup.ValueOrDefault <long>("strLocalizedTextRetrieverStringID", 0);

            cdx.Id = (ulong)(titleId >> 32);

            cdx.Title = TryGetString(cdx.Fqn, titleLookup);
            cdx.Text  = TryGetString(cdx.Fqn, descLookup);
            cdx.Level = (int)obj.Data.ValueOrDefault <long>("cdxLevel", 0);
            if (String.IsNullOrEmpty(cdx.Title))
            {
                cdx.IsHidden = true;
            }

            cdx.Faction  = FactionExtensions.ToFaction((long)obj.Data.ValueOrDefault <long>("cdxFaction", 0));
            cdx.IsPlanet = obj.Data.ValueOrDefault <bool>("cdxIsPlanetCodex", false);

            Dictionary <object, object> classLookup = obj.Data.ValueOrDefault <Dictionary <object, object> >("cdxClassesLookupList", null);

            if (classLookup == null)
            {
                cdx.ClassRestricted = false;
            }
            else
            {
                cdx.ClassRestricted = true;
                cdx.Classes         = new List <ClassSpec>();
                foreach (var kvp in classLookup)
                {
                    if ((bool)kvp.Value)
                    {
                        cdx.Classes.Add(ClassSpecLoader.Load((ulong)kvp.Key));
                    }
                }
            }

            List <object> cdxPlanets = obj.Data.ValueOrDefault <List <object> >("cdxPlanets", null);

            if (cdxPlanets != null)
            {
                cdx.HasPlanets = true;
                cdx.Planets    = new List <Codex>();
                foreach (var planetId in cdxPlanets)
                {
                    cdx.Planets.Add(CodexLoader.Load((ulong)planetId));
                }
            }

            return(cdx);
        }