Beispiel #1
0
        private void TryToLoadConfigsFromXml()
        {
            LoadDefaultConfigs();

            bool configInGswFolder = new FileInfo("scripts/GSW2/GSW2Config.xml").Exists;
            bool config            = new FileInfo("scripts/GSW2Config.xml").Exists;

            if (!configInGswFolder && !config)
            {
                _configReason = "Config doesn't exist";
                throw new Exception("Config doesn't exist");
            }

            var doc = configInGswFolder
                ? XDocument.Load("scripts/GSW2/GSW2Config.xml").Root
                : XDocument.Load("scripts/GSW2Config.xml").Root;

            _configReason = "Hotkeys section";
            var buttonNode = doc.Element("Hotkeys");

            if (buttonNode != null)
            {
                _mainConfig.HelmetKey        = buttonNode.GetKey("GetHelmetKey");
                _mainConfig.CheckKey         = buttonNode.GetKey("CheckKey");
                _mainConfig.HealKey          = buttonNode.GetKey("HealKey");
                _mainConfig.IncreaseRangeKey = buttonNode.GetKey("IncreaseRangeKey");
                _mainConfig.ReduceRangeKey   = buttonNode.GetKey("ReduceRangeKey");
                _mainConfig.BandageKey       = buttonNode.GetKey("BandageKey");
                _mainConfig.PauseKey         = buttonNode.GetKey("PauseKey");
            }

            _configReason = "Player section";
            var playerNode = doc.Element("Player");

            if (playerNode != null)
            {
                _mainConfig.PlayerConfig.WoundedPlayerEnabled = playerNode.Element("GSWPlayerEnabled").GetBool();

                _mainConfig.PlayerConfig.MinimalHealth = playerNode.Element("MinimalHealth").GetInt();
                _mainConfig.PlayerConfig.MaximalHealth = _mainConfig.PlayerConfig.MinimalHealth + 99;

                _mainConfig.PlayerConfig.MaximalPain        = playerNode.Element("MaximalPain").GetFloat();
                _mainConfig.PlayerConfig.PainRecoverSpeed   = playerNode.Element("PainRecoverySpeed").GetFloat();
                _mainConfig.PlayerConfig.BleedHealingSpeed  = playerNode.Element("BleedHealSpeed").GetFloat() / 1000f;
                _mainConfig.PlayerConfig.PoliceCanForgetYou = playerNode.Element("PoliceCanForget").GetBool();
                _mainConfig.PlayerConfig.CanDropWeapon      = playerNode.Element("CanDropWeapon").GetBool();
                _mainConfig.PlayerConfig.MaximalSlowMo      = playerNode.Element("MaximalSlowMo").GetFloat();

                var animationNode = playerNode.Element("Animations");
                _mainConfig.PlayerConfig.NoPainAnim      = animationNode.Attribute("NoPain").Value;
                _mainConfig.PlayerConfig.MildPainAnim    = animationNode.Attribute("MildPain").Value;
                _mainConfig.PlayerConfig.AvgPainAnim     = animationNode.Attribute("AvgPain").Value;
                _mainConfig.PlayerConfig.IntensePainAnim = animationNode.Attribute("IntensePain").Value;
            }

            _configReason = "Peds section";
            var npcNode = doc.Element("Peds");

            if (npcNode != null)
            {
                _mainConfig.NpcConfig.AddingPedRange = npcNode.Element("GSWScanRange").GetFloat();
                _mainConfig.NpcConfig.RemovePedRange = _mainConfig.NpcConfig.AddingPedRange * ADDING_TO_REMOVING_MULTIPLIER;

                _mainConfig.NpcConfig.ShowEnemyCriticalMessages = npcNode.Element("CriticalMessages").GetBool();
                _mainConfig.NpcConfig.ScanOnlyDamaged           = npcNode.Element("ScanOnlyDamaged").GetBool();

                var        targetsNode = npcNode.Element("Targets");
                bool       all         = targetsNode.GetBool("ALL");
                GswTargets targets     = 0;
                if (all)
                {
                    _mainConfig.NpcConfig.Targets = GswTargets.ALL;
                }
                else
                {
                    if (targetsNode.GetBool("COMPANION"))
                    {
                        targets = targets | GswTargets.COMPANION;
                    }

                    if (targetsNode.GetBool("DISLIKE"))
                    {
                        targets = targets | GswTargets.DISLIKE;
                    }

                    if (targetsNode.GetBool("HATE"))
                    {
                        targets = targets | GswTargets.HATE;
                    }

                    if (targetsNode.GetBool("LIKE"))
                    {
                        targets = targets | GswTargets.LIKE;
                    }

                    if (targetsNode.GetBool("NEUTRAL"))
                    {
                        targets = targets | GswTargets.NEUTRAL;
                    }

                    if (targetsNode.GetBool("PEDESTRIAN"))
                    {
                        targets = targets | GswTargets.PEDESTRIAN;
                    }

                    if (targetsNode.GetBool("RESPECT"))
                    {
                        targets = targets | GswTargets.RESPECT;
                    }

                    _mainConfig.NpcConfig.Targets = targets;
                }

                var healthNode = npcNode.Element("PedHealth");
                _mainConfig.NpcConfig.MinStartHealth = healthNode.GetInt("Min");
                _mainConfig.NpcConfig.MaxStartHealth = healthNode.GetInt("Max");

                var painNode = npcNode.Element("MaximalPain");
                _mainConfig.NpcConfig.LowerMaximalPain = painNode.GetFloat("Min");
                _mainConfig.NpcConfig.UpperMaximalPain = painNode.GetFloat("Max");

                var accuracyNode = npcNode.Element("Accuracy");
                _mainConfig.NpcConfig.MinAccuracy = accuracyNode.GetInt("Min");
                _mainConfig.NpcConfig.MaxAccuracy = accuracyNode.GetInt("Max");

                var rateNode = npcNode.Element("ShootRate");
                _mainConfig.NpcConfig.MinShootRate = rateNode.GetInt("Min");
                _mainConfig.NpcConfig.MaxShootRate = rateNode.GetInt("Max");

                _mainConfig.NpcConfig.MaximalPainRecoverSpeed = npcNode.Element("PainRecoverySpeed").GetFloat();
                _mainConfig.NpcConfig.MaximalBleedStopSpeed   = npcNode.Element("BleedHealSpeed").GetFloat() / 1000f;

                var animationNode = npcNode.Element("Animations");
                _mainConfig.NpcConfig.NoPainAnim      = animationNode.Attribute("NoPain").Value;
                _mainConfig.NpcConfig.MildPainAnim    = animationNode.Attribute("MildPain").Value;
                _mainConfig.NpcConfig.AvgPainAnim     = animationNode.Attribute("AvgPain").Value;
                _mainConfig.NpcConfig.IntensePainAnim = animationNode.Attribute("IntensePain").Value;
            }

            _configReason = "Notifications section";
            var noteNode = doc.Element("Notifications");

            if (noteNode != null)
            {
                _mainConfig.Language          = noteNode.Element("Language").Attribute("Value").Value;
                _mainConfig.CommonMessages    = noteNode.Element("Common").GetBool();
                _mainConfig.WarningMessages   = noteNode.Element("Warning").GetBool();
                _mainConfig.AlertMessages     = noteNode.Element("Alert").GetBool();
                _mainConfig.EmergencyMessages = noteNode.Element("Emergency").GetBool();
            }

            _configReason = "Wounds section";
            var woundsNode = doc.Element("Wounds");

            if (woundsNode != null)
            {
                _mainConfig.WoundConfig.MoveRateOnFullPain        = woundsNode.Element("MoveRateOnFullPain").GetFloat();
                _mainConfig.WoundConfig.RealisticNervesDamage     = woundsNode.Element("RealisticNervesDamage").GetBool();
                _mainConfig.WoundConfig.DamageMultiplier          = woundsNode.Element("OverallDamageMult").GetFloat();
                _mainConfig.WoundConfig.DamageDeviation           = woundsNode.Element("DamageDeviation").GetFloat();
                _mainConfig.WoundConfig.PainMultiplier            = woundsNode.Element("OverallPainMult").GetFloat();
                _mainConfig.WoundConfig.PainDeviation             = woundsNode.Element("PainDeviation").GetFloat();
                _mainConfig.WoundConfig.BleedingMultiplier        = woundsNode.Element("OverallBleedingMult").GetFloat();
                _mainConfig.WoundConfig.BleedingDeviation         = woundsNode.Element("BleedingDeviation").GetFloat();
                _mainConfig.WoundConfig.RagdollOnPainfulWound     = woundsNode.Element("RagdollOnPainfulWound").GetBool();
                _mainConfig.WoundConfig.PainfulWoundValue         = woundsNode.Element("PainfulWoundValue").GetFloat();
                _mainConfig.WoundConfig.MinimalChanceForArmorSave = woundsNode.Element("MinimalChanceForArmorSave").GetFloat();
                _mainConfig.WoundConfig.ApplyBandageTime          = woundsNode.Element("ApplyBandageTime").GetFloat();
                _mainConfig.WoundConfig.BandageCost     = woundsNode.Element("BandageCost").GetInt();
                _mainConfig.WoundConfig.SelfHealingRate = woundsNode.Element("SelfHealingRate").GetFloat();
            }

            _configReason = "Weapons section";
            var weaponNode = doc.Element("Weapons");

            if (weaponNode != null)
            {
                var dictionary = new Dictionary <string, float?[]>();

                foreach (XElement element in weaponNode.Elements())
                {
                    var mults = new float?[5];

                    var damageString = element.Attribute("DamageMult");
                    mults[0] = damageString != null
                        ? (float?)float.Parse(damageString.Value, CultureInfo.InvariantCulture)
                        : null;

                    var bleedingString = element.Attribute("BleedingMult");
                    mults[1] = bleedingString != null
                        ? (float?)float.Parse(bleedingString.Value, CultureInfo.InvariantCulture)
                        : null;

                    var painString = element.Attribute("PainMult");
                    mults[2] = painString != null
                        ? (float?)float.Parse(painString.Value, CultureInfo.InvariantCulture)
                        : null;

                    var critString = element.Attribute("CritChance");
                    mults[3] = critString != null
                        ? (float?)float.Parse(critString.Value, CultureInfo.InvariantCulture)
                        : null;

                    var armorString = element.Attribute("ArmorDamage");
                    mults[4] = armorString != null
                        ? (float?)float.Parse(armorString.Value, CultureInfo.InvariantCulture)
                        : null;

                    dictionary.Add(element.Name.LocalName, mults);
                }

                _mainConfig.WoundConfig.DamageSystemConfigs = dictionary;
            }

#if DEBUG
            UI.Notify($"{_mainConfig}");
#endif
        }
Beispiel #2
0
        private static void PedsSection(MainConfig config, XElement doc)
        {
            var node = doc.Element("Peds");

            if (node == null)
            {
                return;
            }

            config.NpcConfig.AddingPedRange = node.Element("GSWScanRange").GetFloat();
            config.NpcConfig.RemovePedRange = config.NpcConfig.AddingPedRange * GunshotWound2.AddingToRemovingMultiplier;

            config.NpcConfig.ShowEnemyCriticalMessages = node.Element("CriticalMessages").GetBool();
            config.NpcConfig.ScanOnlyDamaged           = node.Element("ScanOnlyDamaged").GetBool();

            var healthNode = node.Element("PedHealth");

            config.NpcConfig.MinStartHealth = healthNode.GetInt("Min");
            config.NpcConfig.MaxStartHealth = healthNode.GetInt("Max");

            var painNode = node.Element("MaximalPain");

            config.NpcConfig.LowerMaximalPain = painNode.GetFloat("Min");
            config.NpcConfig.UpperMaximalPain = painNode.GetFloat("Max");

            var accuracyNode = node.Element("Accuracy");

            config.NpcConfig.MinAccuracy = accuracyNode.GetInt("Min");
            config.NpcConfig.MaxAccuracy = accuracyNode.GetInt("Max");

            var rateNode = node.Element("ShootRate");

            config.NpcConfig.MinShootRate = rateNode.GetInt("Min");
            config.NpcConfig.MaxShootRate = rateNode.GetInt("Max");

            config.NpcConfig.MaximalPainRecoverSpeed = node.Element("PainRecoverySpeed").GetFloat();
            config.NpcConfig.MaximalBleedStopSpeed   = node.Element("BleedHealSpeed").GetFloat() / 1000f;

            var        targetsNode = node.Element("Targets");
            var        all         = targetsNode.GetBool("ALL");
            GswTargets targets     = 0;

            if (all)
            {
                config.NpcConfig.Targets = GswTargets.ALL;
                return;
            }

            if (targetsNode.GetBool("COMPANION"))
            {
                targets |= GswTargets.COMPANION;
            }

            if (targetsNode.GetBool("DISLIKE"))
            {
                targets |= GswTargets.DISLIKE;
            }

            if (targetsNode.GetBool("HATE"))
            {
                targets |= GswTargets.HATE;
            }

            if (targetsNode.GetBool("LIKE"))
            {
                targets |= GswTargets.LIKE;
            }

            if (targetsNode.GetBool("NEUTRAL"))
            {
                targets |= GswTargets.NEUTRAL;
            }

            if (targetsNode.GetBool("PEDESTRIAN"))
            {
                targets |= GswTargets.PEDESTRIAN;
            }

            if (targetsNode.GetBool("RESPECT"))
            {
                targets |= GswTargets.RESPECT;
            }

            config.NpcConfig.Targets = targets;

            var animationNode = node.Element("MoveSets");

            if (animationNode == null)
            {
                return;
            }

            config.NpcConfig.MildPainSets    = animationNode.Attribute("MildPain")?.Value.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            config.NpcConfig.AvgPainSets     = animationNode.Attribute("AvgPain")?.Value.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            config.NpcConfig.IntensePainSets = animationNode.Attribute("IntensePain")?.Value.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        }