コード例 #1
0
 public void CustomDifficultyWeightPatch(On.PlayerCharacterStats.orig_OnUpdateWeight original, PlayerCharacterStats instance)
 {
     original.Invoke(instance);
     if (gameData.PouchCapacity != 0 || gameData.BackpackCapacity != 0)
     {
         Character character = (Character)m_character.GetValue(instance);
         Stat      s1        = (Stat)moveField.GetValue(instance);
         Stat      s2        = (Stat)stamRegenField.GetValue(instance);
         Stat      s3        = (Stat)m_staminaUseModifiers.GetValue(instance);
         if ((bool)m_generalBurdenPenaltyActive.GetValue(instance))
         {
             m_generalBurdenRatio.SetValue(instance, 1f);
             m_generalBurdenPenaltyActive.SetValue(instance, false);
             s1.RemoveMultiplierStack("Burden");
             s2.RemoveMultiplierStack("Burden");
             s3.RemoveMultiplierStack("Burden_Dodge");
             s3.RemoveMultiplierStack("Burden_Sprint");
         }
         if (!character.Cheats.NotAffectedByWeightPenalties)
         {
             float totalWeight = character.Inventory.TotalWeight;
             if (totalWeight > gameData.PouchCapacity + gameData.BackpackCapacity)
             {
                 m_generalBurdenPenaltyActive.SetValue(instance, true);
                 float num = totalWeight / gameData.PouchCapacity + gameData.BackpackCapacity;
                 if (num != (float)m_generalBurdenRatio.GetValue(instance))
                 {
                     m_generalBurdenRatio.SetValue(instance, num);
                     s1.AddMultiplierStack("Burden", num * -0.02f);
                     s2.AddMultiplierStack("Burden", num * -0.05f);
                     s3.AddMultiplierStack("Burden_Dodge", num * 0.05f, TagSourceManager.Dodge);
                     s3.AddMultiplierStack("Burden_Sprint", num * 0.05f, TagSourceManager.Sprint);
                 }
             }
         }
         moveField.SetValue(instance, s1);
         stamRegenField.SetValue(instance, s2);
         m_staminaUseModifiers.SetValue(instance, s3);
     }
 }
コード例 #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);
        }