示例#1
0
        // monster switch statement ahead...
        private void SetCustomStat(CharacterStats stats, string stackSource, Tag statTag, float value, bool mult, ModConfig config)
        {
            ClearCustomStat(stats, statTag, stackSource, mult);
            stats.RefreshVitalMaxStat();
            Stat[] _dmg = (Stat[])AT.GetValue(typeof(CharacterStats), stats, "m_damageTypesModifier");
            Stat[] _pro = (Stat[])AT.GetValue(typeof(CharacterStats), stats, "m_damageProtection");
            Stat[] _res = (Stat[])AT.GetValue(typeof(CharacterStats), stats, "m_damageResistance");

            switch (statTag.TagName)
            {
            case "MaxHealth":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_maxHealthStat"), value, CharacterStats.MIN_MAXHEALTH_LIMIT, config)), mult);
                break;

            case "HealthRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_healthRegen"), value, Settings.Minimum, config)), mult);
                break;

            case "HealthBurn":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_burntHealthModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "MaxStamina":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_maxStamina"), value, CharacterStats.MIN_MAXSTAMINA_LIMIT, config)), mult);
                break;

            case "StaminaRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_staminaRegen"), value, Settings.MinimumMod, config)), mult);
                break;

            case "StaminaUse":
            case "StaminaCostReduction":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_staminaUseModifiers"), value, Settings.Minimum, config)), mult);
                break;

            case "StaminaBurn":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_burntStaminaModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "MaxMana":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_maxManaStat"), value, Settings.Minimum, config)), mult);
                break;

            case "ManaRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_manaRegen"), value, Settings.Minimum, config)), mult);
                break;

            case "ManaUse":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_manaUseModifiers"), value, Settings.Minimum, config)), mult);
                break;

            case "ManaBurn":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_burntManaModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "Impact":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_impactModifier"), value, Settings.Minimum, config)), mult);
                break;

            case "AllDamages":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_damageModifiers"), value, Settings.Minimum, config)), mult);
                break;

            case "PhysicalDamage":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _dmg[0].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "EtherealDamage":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _dmg[1].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "DecayDamage":
            case "DarkDamage":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _dmg[2].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "ElectricDamage":
            case "LightDamage":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _dmg[3].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "FrostDamage":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _dmg[4].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "FireDamage":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _dmg[5].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "DamageProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_allDamageProtection"), value, Settings.Minimum, config)), mult);
                break;

            case "PhysicalProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _pro[0].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "EtherealProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _pro[1].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "DecayProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _pro[2].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "ElectricProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _pro[3].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "FrostProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _pro[4].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "FireProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _pro[5].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "DarkProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _pro[6].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "LightProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _pro[7].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "AllResistances":
            case "DamageResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_resistanceModifiers"), value, Settings.Minimum, config)), mult);
                break;

            case "PhysicalResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _res[0].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "EtherealResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _res[1].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "DecayResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _res[2].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "ElectricResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _res[3].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "FrostResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _res[4].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "FireResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _res[5].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "DarkResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _res[6].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "LightResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, _res[7].CurrentValue, value, Settings.Minimum, config)), mult);
                break;

            case "ImpactResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_impactResistance"), value, Settings.Minimum, config)), mult);
                break;

            case "StabilityRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_stabilityRegen"), value, Settings.MinimumMod, config)), mult);
                break;

            case "EnvColdProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_coldProtection"), value, Settings.Minimum, config)), mult);
                break;

            case "EnvHeatProtection":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_heatProtection"), value, Settings.Minimum, config)), mult);
                break;

            case "ColdRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_coldRegenRate"), value, Settings.MinimumMod, config)), mult);
                break;

            case "HeatRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_heatRegenRate"), value, Settings.MinimumMod, config)), mult);
                break;

            case "Waterproof":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_waterproof"), value, Settings.Minimum, config)), mult);
                break;

            case "CorruptionResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_corruptionResistance"), value, Settings.Minimum, config)), mult);
                break;

            case "TemperatureModifier":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_temperatureModifier"), value, Settings.Minimum, config)), mult);
                break;

            case "MovementSpeed":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_movementSpeed"), value, Settings.MinimumMod, config)), mult);
                break;

            case "Speed":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_speedModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "AttackSpeed":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_attackSpeedModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "DodgeInvulnerabilityModifier":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_dodgeInvulneratiblityModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "Detectability":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_detectability"), value, Settings.Minimum, config)), mult);
                break;

            case "VisualDetectability":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_visualDetectability"), value, Settings.Minimum, config)), mult);
                break;

            case "PouchCapacity":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_pouchCapacity"), value, Settings.Minimum, config)), mult);
                break;

            case "FoodEffectEfficiency":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_foodEffectEfficiency"), value, Settings.Minimum, config)), mult);
                break;

            case "SkillCooldownModifier":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_skillCooldownModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "BuyModifier":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_buyModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "SellModifier":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_sellModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "FoodDepleteRate":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetPlayerStat(stats.GetComponent <PlayerCharacterStats>(), "m_foodDepletionRate"), value, Settings.MinimumMod, config)), mult);
                break;

            case "DrinkDepleteRate":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetPlayerStat(stats.GetComponent <PlayerCharacterStats>(), "m_drinkDepletionRate"), value, Settings.MinimumMod, config)), mult);
                break;

            case "SleepDepleteRate":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetPlayerStat(stats.GetComponent <PlayerCharacterStats>(), "m_sleepDepletionRate"), value, Settings.MinimumMod, config)), mult);
                break;
            }
        }
示例#2
0
        // actual function to set an enemy's stats
        private void SetEnemyMods(ModConfig _config, CharacterStats _stats, Character m_character)
        {
            if (m_character == null || !m_character.IsAI || m_character.Faction == Character.Factions.Player)
            {
                //Debug.Log("trying to set stats for a null character, or a non-AI character");
                return;
            }

            if (FixedEnemies.Contains(m_character.UID))
            {
                // Debug.Log("Fixed enemies already contains " + m_character.Name);
                return;
            }

            var m_staminaUseModiifers = new Stat(1f);

            m_staminaUseModiifers.AddMultiplierStack(new StatStack("MyStat", -0.9f));

            if ((bool)_config.GetValue(Settings.Enemy_Balancing))
            {
                string stackSource = "CombatOverhaul";

                if (!PhotonNetwork.isNonMasterClientInRoom)
                {
                    // set health modifier
                    var healthTag   = TagSourceManager.Instance.GetTag("77"); // 77 = max health
                    var healthStack = new StatStack(stackSource, (float)_config.GetValue(Settings.Enemy_Health) - 1);
                    _stats.RemoveStatStack(healthTag, stackSource, true);
                    _stats.AddStatStack(healthTag, healthStack, true);
                    At.SetValue(_stats.CurrentHealth * (float)_config.GetValue(Settings.Enemy_Health), typeof(CharacterStats), _stats, "m_health");
                }

                // set impact resistance
                var impactTag = TagSourceManager.Instance.GetTag("84"); // 84 = impact res
                _stats.RemoveStatStack(impactTag, stackSource, false);
                var impactStack = new StatStack(stackSource, (float)_config.GetValue(Settings.Enemy_ImpactRes));
                _stats.AddStatStack(impactTag, impactStack, false);

                // damage bonus
                var damageTag = TagSourceManager.Instance.GetTag("96"); // 96 = all damage bonus
                _stats.RemoveStatStack(damageTag, stackSource, true);
                var damageStack = new StatStack(stackSource, (float)_config.GetValue(Settings.Enemy_Damages) * 0.01f);
                _stats.AddStatStack(damageTag, damageStack, true);

                // impact modifier
                var impactModifier = At.GetValue(typeof(CharacterStats), _stats, "m_impactModifier") as Stat;
                impactModifier.RemoveStack(stackSource, true);
                impactModifier.AddStack(new StatStack(stackSource, (float)_config.GetValue(Settings.Enemy_ImpactDmg) * 0.01f), true);

                for (int i = 0; i < 6; i++)
                {
                    // damage resistance (Capped at 99, unless already 100)
                    float currentRes = m_character.Stats.GetDamageResistance((DamageType.Types)i);
                    if (currentRes < 100)
                    {
                        var valueToSet = (float)_config.GetValue(Settings.Enemy_Resistances);

                        if (currentRes + valueToSet >= 99)
                        {
                            valueToSet = 99 - currentRes;
                        }

                        int tag          = 113 + i; // 113 to 118 = damage resistance stats
                        var damageResTag = TagSourceManager.Instance.GetTag(tag.ToString());
                        _stats.RemoveStatStack(damageResTag, stackSource, true);
                        var resStack = new StatStack(stackSource, valueToSet);
                        _stats.AddStatStack(damageResTag, resStack, false);
                    }
                }
            }

            if ((bool)_config.GetValue(Settings.All_Enemies_Allied))
            {
                m_character.ChangeFaction(Character.Factions.Bandits);
                m_character.TargetingSystem.AlliedToSameFaction = true;

                Character.Factions[] targets = new Character.Factions[] { Character.Factions.Player };
                At.SetValue(targets, typeof(TargetingSystem), m_character.TargetingSystem, "TargetableFactions");

                // fix skills
                foreach (var uid in m_character.Inventory.SkillKnowledge.GetLearnedActiveSkillUIDs())
                {
                    if (ItemManager.Instance.GetItem(uid) is Skill skill)
                    {
                        foreach (Shooter shooter in skill.GetComponentsInChildren <Shooter>())
                        {
                            shooter.Setup(targets, shooter.transform.parent);
                        }
                    }
                }
            }

            FixedEnemies.Add(m_character.UID);
        }
        // monster switch statement ahead...
        private void SetCustomStat(CharacterStats stats, string stackSource, Tag statTag, float value, bool mult, ModConfig config)
        {
            ClearCustomStat(stats, statTag, stackSource, mult);
            stats.RefreshVitalMaxStat();
            Stat[] _dmg = (Stat[])AT.GetValue(typeof(CharacterStats), stats, "m_damageTypesModifier");
            Stat[] _pro = (Stat[])AT.GetValue(typeof(CharacterStats), stats, "m_damageProtection");
            Stat[] _res = (Stat[])AT.GetValue(typeof(CharacterStats), stats, "m_damageResistance");

            switch (statTag.TagName)
            {
            case "MaxHealth":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_maxHealthStat"), value, CharacterStats.MIN_MAXHEALTH_LIMIT, config)), mult);
                break;

            case "HealthRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_healthRegen"), value, Settings.Minimum, config)), mult);
                break;

            case "MaxStamina":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_maxStamina"), value, CharacterStats.MIN_MAXSTAMINA_LIMIT, config)), mult);
                break;

            case "StaminaRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_staminaRegen"), value, Settings.MinimumMod, config)), mult);
                break;

            case "StaminaUse":
            case "StaminaCostReduction":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_staminaUseModifiers"), value, Settings.Minimum, config)), mult);
                break;

            case "MaxMana":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_maxManaStat"), value, Settings.Minimum, config)), mult);
                break;

            case "ManaRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_manaRegen"), value, Settings.Minimum, config)), mult);
                break;

            case "ManaUse":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_manaUseModifiers"), value, Settings.Minimum, config)), mult);
                break;

            case "Impact":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_impactModifier"), value, Settings.Minimum, config)), mult);
                break;

            case "AllDamages":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_damageModifiers"), value, Settings.Minimum, config)), mult);
                break;

            case "ImpactResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_impactResistance"), value, Settings.Minimum, config)), mult);
                break;

            case "StabilityRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_stabilityRegen"), value, Settings.MinimumMod, config)), mult);
                break;

            case "MovementSpeed":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_movementSpeed"), value, Settings.MinimumMod, config)), mult);
                break;

            case "AttackSpeed":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_attackSpeedModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "DodgeInvulnerabilityModifier":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_dodgeInvulneratiblityModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "Detectability":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_detectability"), value, Settings.Minimum, config)), mult);
                break;

            case "VisualDetectability":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_visualDetectability"), value, Settings.Minimum, config)), mult);
                break;

            case "SkillCooldownModifier":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_skillCooldownModifier"), value, Settings.MinimumMod, config)), mult);
                break;
            }
        }