Esempio n. 1
0
        public static Dictionary <string, StatValues> GetStats()
        {
            Dictionary <string, StatValues> stats = new Dictionary <string, StatValues>();

            int count = HVRPlayerInterfaceAPI.Statistics_GetTrackedValueCount();

            for (int i = 0; i < count; ++i)
            {
                StringBuilder key = new StringBuilder(256);
                StatValues    val = new StatValues();

                if (HVRPlayerInterfaceAPI.Statistics_GetTrackedValueName(i, key))
                {
                    val.max = HVRPlayerInterfaceAPI.Statistics_GetPerFrame(key.ToString(), HVRPlayerInterfaceAPI.STAT_MAX);
                    val.min = HVRPlayerInterfaceAPI.Statistics_GetPerFrame(key.ToString(), HVRPlayerInterfaceAPI.STAT_MIN);
                    val.avg = HVRPlayerInterfaceAPI.Statistics_GetPerFrame(key.ToString(), HVRPlayerInterfaceAPI.STAT_AVG);
                }

                if (!stats.ContainsKey(key.ToString()))
                {
                    stats.Add(key.ToString(), val);
                }
            }

            return(stats);
        }
 public void UnequipStat(StatValues id)
 {
     //Cycles through the stats array and removes the value of the stat from the stat saved here
     for (int i = 0; i < _stats.Length; i++)
     {
         if (_stats[i]._id == id._id)
         {
             _stats[i]._value -= id._value;
         }
     }
 }
Esempio n. 3
0
        private Dictionary <Item, Tuple <float, float> > GetWeaponMults(Dictionary <Item, PassiveSet> plandoPassives, Dictionary <Character, List <PassiveSet> > sets)
        {
            Dictionary <Item, Tuple <float, float> > weaponMults = Items.items.Where(i => i.ID.StartsWith("wea") && i.EquipPassive.Item2 == 0).ToDictionary(i => i, i =>
            {
                PassiveSet s;
                if (plandoPassives.ContainsKey(i))
                {
                    s = plandoPassives[i];
                }
                else if (i.EquipPassive.Item1.LockingLevel == LockingLevel.Fixed)
                {
                    s = i.EquipPassive.Item1;
                }
                else
                {
                    s = sets[GetCharacter(i.ID)][0];
                    sets[GetCharacter(i.ID)].RemoveAt(0);
                }
                if (s.GetPassiveDirect(0, Int32.MaxValue).StrengthModifier > 0 && s.GetPassiveDirect(0, Int32.MaxValue).MagicModifier > 0)
                {
                    if (RandomNum.RandInt(0, 100) < 3)
                    {
                        if (RandomNum.RandInt(0, 100) < 50)
                        {
                            return(new Tuple <float, float>(1.5f, 0));
                        }
                        else
                        {
                            return(new Tuple <float, float>(0, 1.5f));
                        }
                    }
                    else
                    {
                        StatValues strMag = new StatValues(2);
                        strMag.Randomize(75, 0.6f);
                        return(new Tuple <float, float>(strMag[0] / 100f, strMag[1] / 100f));
                    }
                }
                return(new Tuple <float, float>(1, 1));
            });

            weaponMults.Keys.ToList().Where(i => equips[i].UpgradeInto != "").ForEach(i =>
            {
                for (Item i2 = Items.items.Find(i3 => i3.ID == equips[i].UpgradeInto); ; i2 = Items.items.Find(i3 => i3.ID == equips[i2].UpgradeInto))
                {
                    weaponMults.Add(i2, weaponMults[i]);
                    if (equips[i2].UpgradeInto == "")
                    {
                        break;
                    }
                }
            });
            return(weaponMults);
        }
 public void EquipStat(StatValues stat)
 {
     //Cycle through each stat
     for (int i = 0; i < _stats.Length; i++)
     {
         //Check if the stat id is equal to the passed in stat id
         if (_stats[i]._id == stat._id)
         {
             //Add the value to this value
             _stats[i]._value += stat._value;
         }
     }
 }
Esempio n. 5
0
        public override void Randomize(BackgroundWorker backgroundWorker)
        {
            Dictionary <Character, int> plando = main.runSpeedPlando1.GetRunSpeeds();

            if (Flags.Other.RunSpeed)
            {
                Flags.Other.RunSpeed.SetRand();
                StatValues runSpeeds = new StatValues(6);

                Tuple <int, int>[] bounds = runSpeeds.GetVarianceBounds(Flags.Other.RunSpeed.Range.Value);
                for (int i = 0; i < 6; i++)
                {
                    if (plando.ContainsKey((Character)i))
                    {
                        bounds[i] = new Tuple <int, int>(plando[(Character)i] * 100 / 0x60, plando[(Character)i] * 100 / 0x60);
                        characters[GetID((Character)i)].RunSpeed = (byte)plando[(Character)i];
                    }
                }

                runSpeeds.Randomize(bounds, bounds.Where(b => b.Item1 != b.Item2).Count() * Flags.Other.RunSpeed.Range.Value);
                for (int i = 0; i < 6; i++)
                {
                    if (!plando.ContainsKey((Character)i))
                    {
                        characters[GetID((Character)i)].RunSpeed = (byte)Math.Round(0x60 * runSpeeds[i] / 100f);
                    }
                }
                RandomNum.ClearRand();
            }

            if (Tweaks.Boosts.RunSpeedMultiplier)
            {
                for (int i = 0; i < 6; i++)
                {
                    if (!Flags.Other.RunSpeed || !plando.ContainsKey((Character)i))
                    {
                        characters[GetID((Character)i)].RunSpeed = (byte)Math.Round(characters[GetID((Character)i)].RunSpeed * (100 + Tweaks.Boosts.RunSpeedMultiplier.Range.Value) / 100f);
                    }
                }
            }
        }
Esempio n. 6
0
 public Pokemon(string name, PokemonBreed breed, int lvl, int nature, StatValues iv, StatValues ev)
 {
 }
Esempio n. 7
0
        public override void Randomize(BackgroundWorker backgroundWorker)
        {
            Dictionary <Enemy, int[]> plandoStats = main.enemyStatsPlando1.GetStats();
            Dictionary <Enemy, Tuple <Item, Item> > plandoDrops = main.enemyDropPlando1.GetDrops();
            Dictionary <Enemy, Dictionary <Element, ElementalRes> > plandoElementResists = main.enemyElementResistPlando1.GetElementResists();
            Dictionary <Enemy, Dictionary <Debuff, int> >           plandoDebuffResists  = main.enemyDebuffResistPlando1.GetDebuffResists();

            int completed = 0;
            List <DataStoreEnemy> enemyList = Enemies.enemies.Select(eID => enemies[eID.ID]).ToList();

            Enemies.enemies.ForEach(eID =>
            {
                DataStoreEnemy e = enemies[eID];
                byte[] idBytes   = bytes.SubArray(completed * 0x20 + 0x90, 0x10);
                string id        = Encoding.UTF8.GetString(idBytes).Replace("\0", "");

                double hpBase     = 1.1;
                double strMagBase = 1.03;
                double cpBase     = 1.3;

                if (Tweaks.Challenges.BoostLevel)
                {
                    int boost  = Tweaks.Challenges.BoostLevel.Range.Value;
                    e.HP       = (uint)Math.Max(10, e.HP * Math.Pow(hpBase, RandoExtensions.CubeRoot(boost)));
                    e.Strength = (ushort)Math.Max(1, e.Strength * Math.Pow(strMagBase, RandoExtensions.CubeRoot(boost)));
                    e.Magic    = (ushort)Math.Max(1, e.Magic * Math.Pow(strMagBase, RandoExtensions.CubeRoot(boost)));
                }

                if (Flags.EnemyFlags.RandLevel)
                {
                    Flags.EnemyFlags.RandLevel.SetRand();
                    int variance = Flags.EnemyFlags.RandLevel.Range.Value;
                    bool lv0     = e.Level == 0;
                    int level    = lv0 ? 10 : e.Level;
                    if (e.Level < 50)
                    {
                        e.Level = (byte)RandomNum.RandInt(Math.Max(1, e.Level - variance), Math.Min(49, e.Level + variance));
                    }
                    else if (e.Level > 50)
                    {
                        e.Level = (byte)RandomNum.RandInt(Math.Max(51, e.Level - variance), Math.Min(99, e.Level + variance));
                    }
                    if (plandoStats.ContainsKey(eID) && plandoStats[eID][0] > -1)
                    {
                        e.Level = (byte)plandoStats[eID][0];
                    }
                    if (plandoStats.ContainsKey(eID) && plandoStats[eID][6] > -1)
                    {
                        e.CP = (uint)plandoStats[eID][6];
                    }
                    int levelDiff = e.Level - level;

                    e.HP       = (uint)Math.Max(10, e.HP * Math.Pow(hpBase, RandoExtensions.CubeRoot(levelDiff)));
                    e.Strength = (ushort)Math.Max(1, e.Strength * Math.Pow(strMagBase, RandoExtensions.CubeRoot(levelDiff)));
                    e.Magic    = (ushort)Math.Max(1, e.Magic * Math.Pow(strMagBase, RandoExtensions.CubeRoot(levelDiff)));

                    if (e.CP > 0 && (!plandoStats.ContainsKey(eID) || plandoStats[eID][6] == -1))
                    {
                        e.CP = (uint)Math.Max(1, e.CP * Math.Pow(cpBase, RandoExtensions.CubeRoot(levelDiff)));
                    }
                    if (lv0 && (!plandoStats.ContainsKey(eID) || plandoStats[eID][0] == -1))
                    {
                        e.Level = 0;
                    }
                    RandomNum.ClearRand();
                }

                if (Flags.ItemFlags.Drops)
                {
                    if (eID.ParentData != null)
                    {
                        e.CommonDropID = enemies[eID.ParentData].CommonDropID;
                        e.RareDropID   = enemies[eID.ParentData].RareDropID;
                    }
                    else
                    {
                        Flags.ItemFlags.Drops.SetRand();
                        do
                        {
                            RandomizeDrop(e, eID, true, plandoDrops);
                            RandomizeDrop(e, eID, false, plandoDrops);
                        } while (!AreDropsValid(e, eID, plandoDrops));
                        RandomNum.ClearRand();
                    }
                }

                int resistanceModifier = 100, debuffModifier = 100;
                if (Flags.EnemyFlags.RandStats)
                {
                    Flags.EnemyFlags.RandStats.SetRand();
                    StatValues stats = new StatValues(5 + (Flags.EnemyFlags.Resistances ? 1 : 0) + (Flags.EnemyFlags.Debuffs ? 1 : 0));
                    int variance     = Flags.EnemyFlags.RandStats.Range.Value;

                    Tuple <int, int>[] bounds = stats.GetVarianceBounds(variance);
                    if (e.StaggerPoint == 1000)
                    {
                        bounds[4] = new Tuple <int, int>(1000, 1000);
                    }
                    if (plandoStats.ContainsKey(eID))
                    {
                        if (plandoStats[eID][1] > -1)
                        {
                            bounds[0] = new Tuple <int, int>((int)(plandoStats[eID][1] * 100 / Math.Max((int)e.HP, 1)), (int)(plandoStats[eID][1] * 100 / Math.Max((int)e.HP, 1)));
                        }
                        if (plandoStats[eID][2] > -1)
                        {
                            bounds[1] = new Tuple <int, int>((int)(plandoStats[eID][2] * 100 / Math.Max((int)e.Strength, 1)), (int)(plandoStats[eID][2] * 100 / Math.Max((int)e.Strength, 1)));
                        }
                        if (plandoStats[eID][3] > -1)
                        {
                            bounds[2] = new Tuple <int, int>((int)(plandoStats[eID][3] * 100 / Math.Max((int)e.Magic, 1)), (int)(plandoStats[eID][3] * 100 / Math.Max((int)e.Magic, 1)));
                        }
                        if (plandoStats[eID][4] > -1)
                        {
                            bounds[3] = new Tuple <int, int>((int)(plandoStats[eID][4] * 100 / Math.Max((int)e.ChainRes, 1)), (int)(plandoStats[eID][4] * 100 / Math.Max((int)e.ChainRes, 1)));
                        }
                        if (plandoStats[eID][5] > -1)
                        {
                            bounds[4] = new Tuple <int, int>((int)(plandoStats[eID][5] * 100 / Math.Max((int)e.StaggerPoint, 1)), (int)(plandoStats[eID][5] * 100 / Math.Max((int)e.StaggerPoint, 1)));
                        }
                    }

                    if (Flags.EnemyFlags.Resistances && plandoElementResists.ContainsKey(eID) && plandoElementResists[eID].Count == 8)
                    {
                        bounds[5] = new Tuple <int, int>(100, 100);
                    }

                    if (Flags.EnemyFlags.Debuffs && plandoDebuffResists.ContainsKey(eID) && plandoDebuffResists[eID].Count == 11)
                    {
                        bounds[5 + (Flags.EnemyFlags.Resistances ? 1 : 0)] = new Tuple <int, int>(100, 100);
                    }

                    stats.Randomize(bounds, bounds.Where(b => b.Item1 != b.Item2).Count() * variance);
                    e.HP       = (uint)Math.Max(1, e.HP * stats[0] / 100f);
                    e.Strength = (ushort)Math.Max(1, e.Strength * stats[1] / 100f);
                    e.Magic    = (ushort)Math.Max(1, e.Magic * stats[2] / 100f);
                    e.ChainRes = (uint)Math.Min(100, Math.Max(0, Math.Sqrt(Math.Pow(e.ChainRes + 1, 2f) * stats[3] / 100f) - 1));
                    if (bounds[4].Item1 == 1000)
                    {
                        e.StaggerPoint = 1000;
                    }
                    else
                    {
                        e.StaggerPoint = (ushort)Math.Min(999, Math.Max(101, (e.StaggerPoint - 100) * stats[4] / 100f + 100));
                    }
                    RandomNum.ClearRand();
                    if (Flags.EnemyFlags.Resistances)
                    {
                        resistanceModifier = stats[5];
                    }
                    if (Flags.EnemyFlags.Debuffs)
                    {
                        debuffModifier = stats[5 + (Flags.EnemyFlags.Resistances ? 1 : 0)];
                    }
                }

                if (plandoStats.ContainsKey(eID))
                {
                    if (Flags.EnemyFlags.RandStats || Flags.EnemyFlags.RandLevel)
                    {
                        if (plandoStats[eID][1] > -1)
                        {
                            e.HP = (uint)plandoStats[eID][1];
                        }
                        if (plandoStats[eID][2] > -1)
                        {
                            e.Strength = (ushort)plandoStats[eID][2];
                        }
                        if (plandoStats[eID][3] > -1)
                        {
                            e.Magic = (ushort)plandoStats[eID][3];
                        }
                    }
                    if (Flags.EnemyFlags.RandStats)
                    {
                        if (plandoStats[eID][4] > -1)
                        {
                            e.ChainRes = (uint)plandoStats[eID][4];
                        }
                        if (plandoStats[eID][5] > -1)
                        {
                            e.StaggerPoint = (ushort)plandoStats[eID][5];
                        }
                    }
                }

                if (Flags.EnemyFlags.Resistances)
                {
                    Flags.EnemyFlags.Resistances.SetRand();
                    RandomizeElements(e, eID, resistanceModifier, plandoElementResists);
                    RandomNum.ClearRand();
                }

                if (Flags.EnemyFlags.Debuffs)
                {
                    Flags.EnemyFlags.Debuffs.SetRand();
                    RandomizeDebuffs(e, eID, debuffModifier, plandoDebuffResists);
                    RandomNum.ClearRand();
                }

                completed++;
                backgroundWorker.ReportProgress(completed * 100 / enemies.DataList.Count);
            });


            if (Flags.ItemFlags.ShopLocations)
            {
                Flags.ItemFlags.ShopLocations.SetRand();
                List <int> list = scene.IndexesOf(Encoding.UTF8.GetBytes("key_shop_"));

                List <string> shops = list.Select(i => Encoding.UTF8.GetString(scene.SubArray(i, 11))).ToList();
                for (int i = 0; i < shops.Count; i++)
                {
                    shops[i] = randomizers.Get <RandoTreasure>("Treasures").ShopMappings[shops[i]];
                }

                for (int i = 0; i < list.Count; i++)
                {
                    scene.SetSubArray(list[i], Encoding.UTF8.GetBytes(shops[i]));
                }
                RandomNum.ClearRand();
            }
        }
Esempio n. 8
0
        public Dictionary <int, Dictionary <CrystariumType, List <int> > > GetStatAverages()
        {
            Dictionary <int, Dictionary <CrystariumType, List <int> > > statAverages = new Dictionary <int, Dictionary <CrystariumType, List <int> > >();

            Flags.CrystariumFlags.RandStats.SetRand();
            foreach (Role role in Enum.GetValues(typeof(Role)))
            {
                StatValues stats    = new StatValues(3);
                int        variance = Flags.CrystariumFlags.RandStats.Range.Value;
                stats.Randomize(variance);
                roleMults.Add(role, stats);
            }

            foreach (string name in CharNames)
            {
                StatValues stats    = new StatValues(3);
                int        variance = Flags.CrystariumFlags.RandStats.Range.Value;
                stats.Randomize(variance);
                charMults.Add(name, stats);
            }

            for (int stage = 1; stage <= 10; stage++)
            {
                Dictionary <CrystariumType, List <int> > dict = new Dictionary <CrystariumType, List <int> >();
                dict.Add(CrystariumType.HP, new List <int>());
                dict.Add(CrystariumType.Strength, new List <int>());
                dict.Add(CrystariumType.Magic, new List <int>());
                statAverages.Add(stage, dict);
            }

            foreach (string name in crystariums.Keys)
            {
                foreach (DataStoreCrystarium c in crystariums[name].DataList)
                {
                    if (c.Type == CrystariumType.HP || c.Type == CrystariumType.Strength || c.Type == CrystariumType.Magic)
                    {
                        statAverages[c.Stage][c.Type].Add(c.Value);
                    }
                }
            }

            if (Tweaks.Challenges.Stats1StageBehind)
            {
                for (int stage = 10; stage > 1; stage--)
                {
                    statAverages[stage] = statAverages[stage - 1];
                }
                Dictionary <CrystariumType, List <int> > dict = new Dictionary <CrystariumType, List <int> >();
                dict.Add(CrystariumType.HP, new List <int>());
                dict[CrystariumType.HP].Add(0);
                dict.Add(CrystariumType.Strength, new List <int>());
                dict[CrystariumType.HP].Add(0);
                dict.Add(CrystariumType.Magic, new List <int>());
                dict[CrystariumType.HP].Add(0);
                statAverages[1] = dict;
            }

            statAverages.Values.ForEach(d =>
            {
                d.Keys.ForEach(k =>
                {
                    int avg = (int)Math.Ceiling((double)d[k].Sum(v => v) / d[k].Count);
                    d[k].Clear();
                    d[k].Add(avg);
                });
                int avgStrMag = (d[CrystariumType.Strength][0] + d[CrystariumType.Magic][0]) / 2;
                d[CrystariumType.Strength][0] = d[CrystariumType.Magic][0] = (int)Math.Max(1, avgStrMag * 1.04 * 0.7);
                d[CrystariumType.HP][0]       = (int)Math.Max(1, d[CrystariumType.HP][0] * 1.03 * 1.85);
            });
            RandomNum.ClearRand();
            return(statAverages);
        }