예제 #1
0
        protected override bool ParseSetup()
        {
            if (BotBase.ReadBotType(RC) != BotType)
            {
                return(false);
            }

            List <string> CustomData = RC.CustomData.Trim().Replace("\r\n", "\n").Split('\n').ToList();

            foreach (string DataLine in CustomData)
            {
                if (DataLine.Contains("EEM_AI"))
                {
                    continue;
                }
                if (DataLine.Contains("Type"))
                {
                    continue;
                }
                var Data = DataLine.Trim().Split(':');
                Data[1] = Data[1].Trim();
                switch (Data[0].Trim())
                {
                case "Faction":
                    break;

                case "FleeOnlyWhenDamaged":
                    if (!bool.TryParse(Data[1], out FreighterSetup.FleeOnlyWhenDamaged))
                    {
                        DebugWrite("ParseSetup", "AI setup error: FleeOnlyWhenDamaged cannot be parsed");
                        return(false);
                    }
                    break;

                case "FleeTriggerDistance":
                    if (!float.TryParse(Data[1], out FreighterSetup.FleeTriggerDistance))
                    {
                        DebugWrite("ParseSetup", "AI setup error: FleeTriggerDistance cannot be parsed");
                        return(false);
                    }
                    break;

                case "FleeSpeedRatio":
                    if (!float.TryParse(Data[1], out FreighterSetup.FleeSpeedRatio))
                    {
                        DebugWrite("ParseSetup", "AI setup error: FleeSpeedRatio cannot be parsed");
                        return(false);
                    }
                    break;

                case "FleeSpeedCap":
                    if (!float.TryParse(Data[1], out FreighterSetup.FleeSpeedCap))
                    {
                        DebugWrite("ParseSetup", "AI setup error: FleeSpeedCap cannot be parsed");
                        return(false);
                    }
                    break;

                default:
                    DebugWrite("ParseSetup", $"AI setup error: Cannot parse '{DataLine}'");
                    return(false);
                }
            }

            FreighterSetup.Default();
            return(true);
        }
예제 #2
0
파일: Fighter.cs 프로젝트: Cheetah97/EEM
        protected override bool ParseSetup()
        {
            if (BotBase.ReadBotType(RC) != BotType)
            {
                return(false);
            }

            List <string> CustomData = RC.CustomData.Trim().Replace("\r\n", "\n").Split('\n').ToList();

            foreach (string DataLine in CustomData)
            {
                if (DataLine.Contains("EEM_AI"))
                {
                    continue;
                }
                if (DataLine.Contains("Type"))
                {
                    continue;
                }
                var Data = DataLine.Trim().Split(':');
                Data[0] = Data[0].Trim();
                Data[1] = Data[1].Trim();

                switch (Data[0])
                {
                case "Faction":
                    break;

                case "Preset":
                    FighterSetup.Preset = Data[1];
                    break;

                case "DelayedAI":
                    if (!bool.TryParse(Data[1], out FighterSetup.DelayedAIEnable))
                    {
                        DebugWrite("ParseSetup", "AI setup error: DelayedAI cannot be parsed");
                        return(false);
                    }
                    break;

                case "AssignToPirates":
                    if (!bool.TryParse(Data[1], out FighterSetup.AssignToPirates))
                    {
                        DebugWrite("ParseSetup", "AI setup error: AssignToPirates cannot be parsed");
                        return(false);
                    }
                    break;

                case "AttackNeutrals":
                    if (!bool.TryParse(Data[1], out FighterSetup.AttackNeutrals))
                    {
                        DebugWrite("ParseSetup", "AI setup error: AttackNeutrals cannot be parsed");
                        return(false);
                    }
                    break;

                case "AmbushMode":
                    if (!bool.TryParse(Data[1], out FighterSetup.AmbushMode))
                    {
                        DebugWrite("ParseSetup", "AI setup error: AmbushMode cannot be parsed");
                        return(false);
                    }
                    break;

                case "SeekDistance":
                    if (!float.TryParse(Data[1], out FighterSetup.SeekDistance))
                    {
                        DebugWrite("ParseSetup", "AI setup error: SeekDistance cannot be parsed");
                        return(false);
                    }
                    break;

                case "ActivationDistance":
                    if (!float.TryParse(Data[1], out FighterSetup.AIActivationDistance))
                    {
                        DebugWrite("ParseSetup", "AI setup error: ActivationDistance cannot be parsed");
                        return(false);
                    }
                    break;

                case "PlayerPriority":
                    DebugWrite("ParseSetup", "AI setup warning: PlayerPriority is deprecated and no longer used.");
                    break;

                case "CallHelpProbability":
                    int probability;
                    if (!int.TryParse(Data[1], out probability))
                    {
                        DebugWrite("ParseSetup", "AI setup error: CallHelpProbability cannot be parsed");
                        return(false);
                    }
                    else if (probability < 0 || probability > 100)
                    {
                        DebugWrite("ParseSetup", "AI setup error: CallHelpProbability out of bounds. Must be between 0 and 100");
                        return(false);
                    }
                    else
                    {
                        FighterSetup.CallHelpProbability = probability;
                    }
                    break;

                case "ThrustMultiplier":
                    float multiplier;
                    if (!float.TryParse(Data[1], out multiplier))
                    {
                        DebugWrite("ParseSetup", "AI setup error: ThrustMultiplier cannot be parsed");
                        return(false);
                    }
                    else
                    {
                        ApplyThrustMultiplier(multiplier);
                    }
                    break;

                default:
                    DebugWrite("ParseSetup", $"AI setup error: Cannot parse '{DataLine}'");
                    return(false);
                }
            }
            FighterSetup.Default();
            return(true);
        }