Beispiel #1
0
        private static string TryGetString(string fqn, GomObjectData textRetriever)
        {
            string locBucket  = textRetriever.ValueOrDefault <string>("strLocalizedTextRetrieverBucket", null);
            long   strId      = textRetriever.ValueOrDefault <long>("strLocalizedTextRetrieverStringID", -1);
            string defaultStr = textRetriever.ValueOrDefault <string>("strLocalizedTextRetrieverDesignModeText", String.Empty);

            if ((locBucket == null) || (strId == -1))
            {
                return(defaultStr);
            }

            StringTable strTable = null;

            try
            {
                strTable = StringTable.Find(locBucket);
            }
            catch
            {
                strTable = null;
            }

            if (strTable == null)
            {
                return(defaultStr);
            }

            string result = strTable.GetText(strId, fqn);

            return(result ?? defaultStr);
        }
Beispiel #2
0
        private static string LoadParamDamageChild(float multi, GomObjectData action, bool isWeapon)
        {
            var floatParams = (Dictionary <object, object>)action.Get <Dictionary <object, object> >("effFloatParams");
            //
            float flurrMin = floatParams.Keys.Where(i => ((ScriptEnum)i).ToString() == "effParam_FlurryBlowsMin").Count() > 0 ? (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_FlurryBlowsMin").Value : 0f;
            float flurrMax = floatParams.Keys.Where(i => ((ScriptEnum)i).ToString() == "effParam_FlurryBlowsMax").Count() > 0 ? (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_FlurryBlowsMax").Value : 0f;
            float threatPerc = floatParams.Keys.Where(i => ((ScriptEnum)i).ToString() == "effParam_ThreatParam").Count() > 0 ? (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_ThreatParam").Value : 0f;
            float stdHpMin = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_StandardHealthPercentMin").Value;
            float stdHpMax = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_StandardHealthPercentMax").Value;
            float modFMin = floatParams.Keys.Where(i => ((ScriptEnum)i).ToString() == "effParam_AmountModifierFixedMin").Count() > 0 ? (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_AmountModifierFixedMin").Value : 0f;
            float modFMax = floatParams.Keys.Where(i => ((ScriptEnum)i).ToString() == "effParam_AmountModifierFixedMax").Count() > 0 ? (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_AmountModifierFixedMax").Value : 0f;
            float modPct = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_AmountModifierPercent").Value;
            float coeff = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_Coefficient").Value;
            float amtMin = 0; float amtMax = 0; float amtPct = 0;

            if (!isWeapon)
            {
                amtMin = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_AmountMin").Value;
                amtMax = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_AmountMax").Value;
                amtPct = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_AmountPercent").Value;
            }

            if (amtMin != 0)
            {
                return(String.Format("damage,{0},{1},{2},{3},{4},{5}",
                                     flurrMin, flurrMax, threatPerc, multi, amtMin, amtMax));
            }
            else
            {
                return(String.Format("damage,{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}",
                                     flurrMin, flurrMax, threatPerc, isWeapon ? 'w' : 's', multi, coeff, stdHpMin, stdHpMax, modFMin, modFMax, modPct));
            }
        }
Beispiel #3
0
        public Models.PackageAbility Load(GomObjectData gomObj)
        {
            GomObjectData obj = gomObj;

            Models.PackageAbility result = new Models.PackageAbility();
            result.AbilityId   = obj.ValueOrDefault <ulong>("ablAbilityDataSpec", 0);
            result.AutoAcquire = gomObj.ValueOrDefault <bool>("ablAbilityDataAutoAcquire", false);
            // result.CategoryName =
            // result.CategoryNameId

            // result.IsTalent
            result.PackageId = obj.ValueOrDefault <ulong>("ablAbilityDataPackage", 0);
            List <object> ranks = obj.ValueOrDefault <List <object> >("ablAbilityDataRanks", null);

            foreach (var rank in ranks)
            {
                result.Levels.Add((int)(long)rank);
            }
            if (result.Levels.Count > 0)
            {
                result.Level = result.Levels[0];
            }
            result.Scales = (result.Levels.Count == 50);
            // result.Rank =
            // result.Toughness =

            result.Ability = AbilityLoader.Load(result.AbilityId);
            return(result);
        }
Beispiel #4
0
        public static Models.ItemSet Load(Models.ItemSet set, GomObjectData obj)
        {
            if (obj == null)
            {
                return(set);
            }
            if (set == null)
            {
                return(null);
            }

            set.Id     = (ulong)obj.ValueOrDefault <long>("itmSetBonusDisplayName", 0);
            set.NameId = (int)obj.ValueOrDefault <long>("itmSetBonusDisplayName", 0);
            set.Name   = strTable.GetText(NameOffset + set.NameId, "ItemSet." + set.Id);
            set.Count  = (int)obj.ValueOrDefault <long>("itmSetBonusItemCount", 0);

            Dictionary <object, object> setItems = obj.ValueOrDefault <Dictionary <object, object> >("itmSetBonusSetItems", null);

            set.SetItems = new List <ItemSetItem>();
            foreach (var itm_itm in setItems)
            {
                ulong itmId         = (ulong)itm_itm.Key;
                ulong primaryItemId = (ulong)itm_itm.Value;

                var itm  = ItemLoader.Load(itmId);
                var pItm = ItemLoader.Load(primaryItemId);

                var setItm = new ItemSetItem();
                setItm.Item        = itm;
                setItm.PrimaryItem = pItm;
                setItm.ItemSet     = set;
                set.SetItems.Add(setItm);
            }

            //List<object> primaryItems = obj.itmSetBonusPrimaryItems;
            //set.PrimaryItems = new List<Item>();
            //foreach (ulong itemNodeId in primaryItems)
            //{
            //    var itm = ItemLoader.Load(itemNodeId);
            //    set.PrimaryItems.Add(itm);
            //}

            Dictionary <object, object> bonusAbilities = obj.ValueOrDefault <Dictionary <object, object> >("itmSetBonusBonuses", null);

            set.Abilities = new List <ItemSetAbility>();
            foreach (var cnt_abl in bonusAbilities)
            {
                int   cnt       = (int)(long)cnt_abl.Key;
                ulong ablNodeId = (ulong)cnt_abl.Value;

                var abl = AbilityLoader.Load(ablNodeId);

                ItemSetAbility setAbl = new ItemSetAbility();
                setAbl.Ability   = abl;
                setAbl.ItemCount = cnt;
                setAbl.ItemSet   = set;
                set.Abilities.Add(setAbl);
            }
            return(set);
        }
Beispiel #5
0
        public static QuestTask Load(GomObjectData obj, QuestStep step)
        {
            QuestTask task = new QuestTask();

            task.Step = step;
            task.Id   = (int)obj.ValueOrDefault <long>("qstTaskId", 0);

            task.CountMax     = (int)obj.ValueOrDefault <long>("qstTaskCountMax", 0);
            task.ShowTracking = obj.ValueOrDefault <bool>("qstTaskShowTracking", false);
            task.ShowCount    = obj.ValueOrDefault <bool>("qstTaskShowTrackingCount", false);
            task.Hook         = QuestHookExtensions.ToQuestHook((string)obj.ValueOrDefault <string>("qstHook", null));
            long stringId = 0;

            long.TryParse(obj.ValueOrDefault <string>("qstTaskStringid", null), out stringId);

            var txtLookup = step.Branch.Quest.TextLookup;

            if (txtLookup.ContainsKey(stringId))
            {
                task.String = StringTable.TryGetString(step.Branch.Quest.Fqn, (GomObjectData)txtLookup[stringId]);
            }

            task.TaskQuests = new List <Quest>();
            task.TaskNpcs   = new List <Npc>();
            var qstTaskObjects = (Dictionary <object, object>)obj.ValueOrDefault <Dictionary <object, object> >("qstTaskObjects", null);

            if (qstTaskObjects != null)
            {
                foreach (var taskObj in qstTaskObjects)
                {
                    string fqn = (string)taskObj.Key;
                    if (fqn.StartsWith("qst."))
                    {
                        var qst = QuestLoader.Load(fqn);
                        task.TaskQuests.Add(qst);
                    }
                    else if (fqn.StartsWith("npc."))
                    {
                        var npc = NpcLoader.Load(fqn);
                        task.TaskNpcs.Add(npc);
                    }
                    else if (fqn.StartsWith("plc."))
                    {
                    }
                }
            }

            return(task);
        }
Beispiel #6
0
        public static QuestStep Load(GomObjectData obj, QuestBranch branch)
        {
            QuestStep step = new QuestStep();

            step.Id          = (int)obj.ValueOrDefault <long>("qstStepId", 0);
            step.Branch      = branch;
            step.IsShareable = obj.ValueOrDefault <bool>("qstStepIsShareable", false);

            step.Tasks = new List <QuestTask>();
            var tasks = (List <object>)obj.ValueOrDefault <List <object> >("qstTasks", null);

            if (tasks != null)
            {
                foreach (var taskDef in tasks)
                {
                    var tsk = QuestTaskLoader.Load((GomObjectData)taskDef, step);
                    step.Tasks.Add(tsk);
                }
            }

            var stringIds = (List <object>)obj.ValueOrDefault <List <object> >("qstStepJournalEntryStringIdList", null);
            var strings   = new List <string>();

            if (stringIds != null)
            {
                var txtLookup = branch.Quest.TextLookup;
                foreach (var strId in stringIds)
                {
                    long key = (long)(ulong)strId;
                    if (txtLookup.ContainsKey(key))
                    {
                        strings.Add(StringTable.TryGetString(branch.Quest.Fqn, (GomObjectData)txtLookup[key]));
                    }
                    else
                    {
                        strings.Add(String.Empty);
                    }
                }
            }

            step.JournalText = String.Join("\n\n", strings.ToArray());

            return(step);
        }
Beispiel #7
0
        private static string LoadParamDuration(GomObjectData tokDesc, List <object> abilityEffectList)
        {
            float duration       = 1;
            int   tokEffIndex    = (int)tokDesc.Get <long>("ablDescriptionTokenEffect");
            int   tokSubEffIndex = (int)tokDesc.Get <long>("ablDescriptionTokenSubEffect");

            if (tokEffIndex >= abilityEffectList.Count)
            {
                // Effect is out of range, so just put a 0 here for the duration.
                duration = 0;
            }
            else
            {
                var tokEff = DataObjectModel.GetObject((ulong)abilityEffectList[tokEffIndex]);
                if (tokSubEffIndex < 1)
                {
                    duration = (float)((ulong)tokEff.Data.ValueOrDefault <ulong>("effDuration", 0)) / 1000;
                }
                else
                {
                    var tokSubEffInitializers = ((GomObjectData)tokEff.Data.Get <List <object> >("effSubEffects")[tokSubEffIndex - 1]).Get <List <object> >("effInitializers");
                    foreach (GomObjectData effInit in tokSubEffInitializers)
                    {
                        if (effInit.Get <object>("effInitializerName").ToString() == "effInitializer_SetDuration")
                        {
                            var durationMap = effInit.Get <Dictionary <object, object> >("field_40000004E27E11D1");
                            foreach (var durKvp in durationMap)
                            {
                                if (((ScriptEnum)durKvp.Key).Value == 0xA2)
                                {
                                    duration = (float)durKvp.Value / 1000;
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
            }

            return(String.Format("duration,{0}", duration));
        }
        public static QuestBranch Load(GomObjectData obj, Quest qst)
        {
            QuestBranch branch = new QuestBranch();

            branch.Quest = qst;
            branch.Id    = (int)obj.ValueOrDefault <long>("qstBranchId", 0);

            var qstSteps = obj.ValueOrDefault <List <object> >("qstSteps", null);

            branch.Steps = new List <QuestStep>();
            if (qstSteps != null)
            {
                foreach (var step in qstSteps)
                {
                    branch.Steps.Add(QuestStepLoader.Load((GomObjectData)step, branch));
                }
            }

            return(branch);
        }
Beispiel #9
0
        public static Models.Area Load(Models.Area area, GomObjectData obj)
        {
            if (obj == null)
            {
                return(area);
            }
            if (area == null)
            {
                return(null);
            }

            IDictionary <string, object> objAsDict = obj.Dictionary;

            if (objAsDict.ContainsKey("mapAreasDataDisplayNameId") && objAsDict.ContainsKey("mapAreasDataDefaultZoneName"))
            {
                area.DisplayNameId = obj.ValueOrDefault <long>("mapAreasDataDisplayNameId", 0);
                area.Id            = (int)(area.DisplayNameId & 0x7FFFFFFF);
                area.CommentableId = Guid.NewGuid();
                area.Name          = strTable.GetText(area.DisplayNameId, "MapArea." + area.DisplayNameId);
                area.AreaId        = obj.ValueOrDefault <ulong>("mapAreasDataAreaId", 0);
                area.ZoneName      = obj.ValueOrDefault <string>("mapAreasDataDefaultZoneName", null);

                string mapDataPath = String.Format("world.areas.{0}.mapdata", area.AreaId);
                var    mapDataObj  = DataObjectModel.GetObject(mapDataPath);
                if (mapDataObj != null)
                {
                    LoadMapdata(area, mapDataObj);
                }
                else
                {
                    Console.WriteLine("No MapData for " + area.Name);
                    area.Id = 0;
                }
            }
            else
            {
                area.Id = 0;
            }

            return(area);
        }
Beispiel #10
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);
        }
        static DialogNode LoadDialogNode(Conversation cnv, GomObjectData data)
        {
            DialogNode result = new DialogNode();

            result.NodeId    = (int)data.Get <long>("cnvNodeNumber");
            result.MinLevel  = (int)data.ValueOrDefault <long>("cnvLevelConditionMin", -1);
            result.MaxLevel  = (int)data.ValueOrDefault <long>("cnvLevelConditionMax", -1);
            result.IsEmpty   = data.ValueOrDefault <bool>("cnvIsEmpty", false);
            result.IsAmbient = data.ValueOrDefault <bool>("cnvIsAmbient", false);
            result.JoinDisabledForHolocom   = data.ValueOrDefault <bool>("cnvIsJoinDisabledForHolocom", false);
            result.ChoiceDisabledForHolocom = data.ValueOrDefault <bool>("cnvIsVoteWinDisabledForHolocom", false);
            result.AbortsConversation       = data.ValueOrDefault <bool>("cnvAbortConversation", false);
            result.IsPlayerNode             = data.ValueOrDefault <bool>("cnvIsPcNode", false);

            result.ActionHook = QuestHookExtensions.ToQuestHook(data.ValueOrDefault <string>("cnvActionHook", null));

            // Load Alignment Results
            long alignmentAmount = data.ValueOrDefault <long>("cnvRewardForceAmount", 0);

            if (alignmentAmount != 0)
            {
                string forceType = data.Get <ScriptEnum>("cnvRewardForceType").ToString();
                result.AlignmentGain = ConversationAlignmentExtensions.ToConversationAlignment(alignmentAmount, forceType);
            }

            // Load Companion Affection Results
            var affectionGains = data.ValueOrDefault <Dictionary <object, object> >("cnvRewardAffectionRewards", null);

            result.AffectionRewards = new Dictionary <Npc, ConversationAffection>();
            if (affectionGains != null)
            {
                foreach (var companionGain in affectionGains)
                {
                    long companionShortNameId           = (long)companionGain.Key;
                    ConversationAffection affectionGain = ConversationAffectionExtensions.ToConversationAffection((long)companionGain.Value);
                    Npc companion = CompanionBySimpleNameId(companionShortNameId);
                    result.AffectionRewards[companion] = affectionGain;
                }
            }

            // Get Text
            var           textMap = data.Get <Dictionary <object, object> >("locTextRetrieverMap");
            GomObjectData txtData = (GomObjectData)textMap[(long)result.NodeId];

            result.Text = StringTable.TryGetString(cnv.Fqn, txtData);

            result.ChildIds = new List <int>();
            foreach (long childId in data.Get <List <object> >("cnvChildNodes"))
            {
                result.ChildIds.Add((int)childId);
            }

            // Load Quests
            var actionQuest = data.ValueOrDefault <ulong>("cnvActionQuest", 0);

            if (actionQuest > 0)
            {
                result.ActionQuest = QuestLoader.Load(actionQuest);
            }

            var questReward = data.ValueOrDefault <ulong>("cnvRewardQuest", 0);

            if (questReward > 0)
            {
                result.QuestReward = QuestLoader.Load(questReward);
            }

            var questGrants = data.Get <Dictionary <object, object> >("cnvNodeQuestGrants");

            result.QuestsGranted = new List <Quest>();
            foreach (var grant in questGrants)
            {
                if ((bool)grant.Value)
                {
                    Quest q = QuestLoader.Load((ulong)grant.Key);
                    result.QuestsGranted.Add(q);
                }
            }

            var questEnds = data.Get <Dictionary <object, object> >("cnvNodeQuestEnds");

            result.QuestsEnded = new List <Quest>();
            foreach (var ends in questEnds)
            {
                if ((bool)ends.Value)
                {
                    Quest q = QuestLoader.Load((ulong)ends.Key);
                    result.QuestsEnded.Add(q);
                }
            }

            var questProgress = data.Get <Dictionary <object, object> >("cnvNodeQuestProgress");

            result.QuestsProgressed = new List <Quest>();
            foreach (var prog in questProgress)
            {
                if ((bool)prog.Value)
                {
                    Quest q = QuestLoader.Load((ulong)prog.Key);
                    result.QuestsProgressed.Add(q);
                }
            }

            return(result);
        }
Beispiel #12
0
        private static string LoadParamHealing(GomObjectData tokDesc, List <object> abilityEffectList)
        {
            int   tokEffIndex    = (int)tokDesc.ValueOrDefault <long>("ablDescriptionTokenEffect", 0);
            int   tokSubEffIndex = (int)tokDesc.ValueOrDefault <long>("ablDescriptionTokenSubEffect", 0);
            float multi          = (float)tokDesc.ValueOrDefault <float>("ablDescriptionTokenMultiplier", 0f);

            if (tokEffIndex < abilityEffectList.Count)
            {
                // Effect is in-range, find the coefficients for healing formula
                var tokEff = DataObjectModel.GetObject((ulong)abilityEffectList[tokEffIndex]);
                if (tokEff == null)
                {
                    return("healing");
                }

                var           tokSubEffects = (List <object>)tokEff.Data.ValueOrDefault <List <object> >("effSubEffects", null);
                GomObjectData action        = null;
                // Loop through subEffects
                if ((tokSubEffIndex >= 0) && (tokSubEffIndex < tokSubEffects.Count))
                {
                    GomObjectData subEff = (GomObjectData)tokSubEffects[tokSubEffIndex];
                    foreach (GomObjectData a in subEff.ValueOrDefault <List <object> >("effActions", null))
                    {
                        if (((ScriptEnum)a.ValueOrDefault <ScriptEnum>("effActionName", null)).ToString() == "effAction_Heal")
                        {
                            action = a;
                            break;
                        }
                    }
                }
                else
                {
                    foreach (GomObjectData subEff in tokSubEffects)
                    {
                        var effActions = (List <object>)subEff.ValueOrDefault <List <object> >("effActions", null);
                        foreach (GomObjectData a in effActions)
                        {
                            if (((ScriptEnum)a.ValueOrDefault <ScriptEnum>("effActionName", null)).ToString() == "effAction_Heal")
                            {
                                action = a;
                                break;
                            }
                        }
                        if (action != null)
                        {
                            break;
                        }
                    }
                }

                if (action == null)
                {
                    return("healing");
                }

                var   floatParams = (Dictionary <object, object>)action.ValueOrDefault <Dictionary <object, object> >("effFloatParams", null);
                float amtMin      = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_AmountMin").Value;
                float amtMax      = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_AmountMax").Value;
                float amtPct      = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_AmountPercent").Value;
                float stdHpMin    = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_StandardHealthPercentMin").Value;
                float stdHpMax    = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_StandardHealthPercentMax").Value;
                float coeff       = (float)floatParams.First(kvp => ((ScriptEnum)kvp.Key).ToString() == "effParam_HealingPowerCoefficient").Value;

                if (amtMin != 0)
                {
                    return(String.Format("healing,{0},{1},{2}", multi, amtMin, amtMax));
                }
                else
                {
                    return(String.Format("healing,{0},{1},{2},{3}", multi, coeff, stdHpMin, stdHpMax));
                }
            }

            return("healing");
        }
Beispiel #13
0
        private static List <string> LoadParamDamage(GomObjectData tokDesc, List <object> abilityEffectList)
        {
            int   tokEffIndex    = (int)tokDesc.ValueOrDefault <long>("ablDescriptionTokenEffect", 0);
            int   tokSubEffIndex = (int)tokDesc.ValueOrDefault <long>("ablDescriptionTokenSubEffect", 0);
            float multi          = (float)tokDesc.ValueOrDefault <float>("ablDescriptionTokenMultiplier", 0f);

            if (!(tokEffIndex < abilityEffectList.Count))
            {
                return(new List <string>()
                {
                    "damage"
                });
            }
            // Effect is in-range, find the coefficients for dmg formula
            GomObject tokEff = null;

            if (tokEffIndex >= 0)
            {
                tokEff = DataObjectModel.GetObject((ulong)abilityEffectList[tokEffIndex]);
            }
            else
            {
                foreach (ulong ablEffId in abilityEffectList)
                {
                    tokEff = DataObjectModel.GetObject(ablEffId);
                    if (tokEff == null)
                    {
                        continue;
                    }
                    if (HasDamageAction(tokEff))
                    {
                        break;
                    }
                    else
                    {
                        tokEff = null;
                    }
                }
            }
            if (tokEff == null)
            {
                return(new List <string>()
                {
                    "damage"
                });
            }

            var tokSubEffects             = (List <object>)tokEff.Data.ValueOrDefault <List <object> >("effSubEffects", null);
            List <GomObjectData> actions  = new List <GomObjectData>();
            List <bool>          isWeapon = new List <bool>();

            // Loop through subEffects
            if ((tokSubEffIndex >= 0) && (tokSubEffIndex < tokSubEffects.Count))
            {
                GomObjectData subEff = (GomObjectData)tokSubEffects[tokSubEffIndex];
                foreach (GomObjectData a in subEff.ValueOrDefault <List <object> >("effActions", null))
                {
                    switch (((ScriptEnum)a.ValueOrDefault <ScriptEnum>("effActionName", null)).ToString())
                    {
                    case "effAction_WeaponDamage": { actions.Add(a); isWeapon.Add(true); break; }

                    case "effAction_SpellDamage": { actions.Add(a); isWeapon.Add(false); break; }
                    }
                }
            }
            else
            {
                foreach (GomObjectData subEff in tokSubEffects)
                {
                    var effActions = (List <object>)subEff.Get <List <object> >("effActions");
                    foreach (GomObjectData a in effActions)
                    {
                        var b = ((ScriptEnum)a.Get <ScriptEnum>("effActionName")).ToString();
                        switch (b)
                        {
                        case "effAction_WeaponDamage": { actions.Add(a); isWeapon.Add(true); break; }

                        case "effAction_SpellDamage": { actions.Add(a); isWeapon.Add(false); break; }
                        }
                    }
                    //if (actions != null) { break; }
                }
            }

            if (actions == null || actions.Count <= 0)
            {
                return(new List <string>()
                {
                    "damage"
                });
            }
            var retVal = new List <string>();

            for (int i = 0; i < actions.Count; i++)
            {
                retVal.Add(LoadParamDamageChild(multi, actions[i], isWeapon[i]));
            }

            return(retVal);
        }
Beispiel #14
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);
        }
Beispiel #15
0
        public static Models.Companion Load(Models.Companion cmp, ulong npcId, GomObjectData obj)
        {
            if (obj == null)
            {
                return(cmp);
            }
            if (cmp == null)
            {
                return(null);
            }

            IDictionary <string, object> objAsDict = obj.Dictionary;

            cmp.Npc      = NpcLoader.Load(npcId);
            cmp.Name     = cmp.Npc.Name;
            cmp.Id       = cmp.Npc.Id;
            cmp.Portrait = ParsePortrait((string)obj.Dictionary["chrCompanionInfo_portrait"]);
            cmp.ConversationMultiplier = (float)obj.Dictionary["chrCompanionInfo_affectionMultiplier"];
            cmp.Classes = new List <ClassSpec>();

            Dictionary <object, object> profMods = (Dictionary <object, object>)obj.Dictionary["chrCompanionInfo_profession_modifiers"];

            cmp.ProfessionModifiers = new List <CompanionProfessionModifier>();
            foreach (var profKvp in profMods)
            {
                CompanionProfessionModifier mod = new CompanionProfessionModifier();
                mod.Companion = cmp;
                mod.Stat      = StatExtensions.ToStat((ScriptEnum)profKvp.Key);
                mod.Modifier  = (int)(long)profKvp.Value;
                cmp.ProfessionModifiers.Add(mod);
            }

            Dictionary <object, object> giftInterestMap = (Dictionary <object, object>)obj.Dictionary["chrCompanionInfo_gift_interest_unromanced_map"];

            cmp.GiftInterest = new List <CompanionGiftInterest>();
            foreach (var giftKvp in giftInterestMap)
            {
                CompanionGiftInterest cgi = new CompanionGiftInterest();
                cgi.Companion = cmp;
                cgi.GiftType  = GiftTypeExtensions.ToGiftType((ScriptEnum)giftKvp.Key);
                cgi.Reaction  = GiftInterestExtensions.ToGiftInterest((ScriptEnum)giftKvp.Value);
                cmp.GiftInterest.Add(cgi);
            }

            giftInterestMap = (Dictionary <object, object>)obj.Dictionary["chrCompanionInfo_gift_interest_romanced_map"];
            foreach (var giftKvp in giftInterestMap)
            {
                GiftType gftType = GiftTypeExtensions.ToGiftType((ScriptEnum)giftKvp.Key);
                var      cgi     = cmp.GiftInterest.First(x => x.GiftType == gftType);
                cgi.RomancedReaction = GiftInterestExtensions.ToGiftInterest((ScriptEnum)giftKvp.Value);
                cmp.IsRomanceable    = true;
            }
            if (!cmp.IsRomanceable)
            {
                // Force Malavai Quinn and Lt. Pierce to be listed as romanceable
                if (cmp.Name.Contains("Quinn") || (cmp.Name.Contains("Pierce")))
                {
                    cmp.IsRomanceable = true;
                }
            }

            cmp.AffectionRanks = new List <CompanionAffectionRank>();
            List <object> affectionRanks = (List <object>)obj.Dictionary["chrCompanionInfo_threshold_list"];
            int           rank           = 0;

            foreach (long aff in affectionRanks)
            {
                CompanionAffectionRank car = new CompanionAffectionRank();
                car.Companion = cmp;
                car.Rank      = rank;
                car.Affection = (int)aff;
                cmp.AffectionRanks.Add(car);
                rank++;
            }

            return(cmp);
        }