Ejemplo n.º 1
0
 public static void SetPlayer(IPlayer player, BotType botType)
 {
     if (botType == BotType.None)
     {
         return;
     }
     BotManager.SpawnBot(botType, BotFaction.None, player, player.GetTeam());
 }
Ejemplo n.º 2
0
        public static void CreateNewBot(IEnumerable <string> arguments)
        {
            if (arguments.Count() < 1)
            {
                return;
            }

            var botTypeStr = arguments.First();
            var botType    = BotType.None;

            if (SharpHelper.TryParseEnum(botTypeStr, out botType))
            {
                arguments = arguments.Skip(1);
            }
            else
            {
                ScriptHelper.PrintMessage("--BotExtended spawn bot--", ScriptHelper.ERROR_COLOR);
                ScriptHelper.PrintMessage("Invalid query: " + botTypeStr, ScriptHelper.WARNING_COLOR);
                return;
            }

            var team = PlayerTeam.Independent;

            if (arguments.Any())
            {
                if (TryParseTeam(arguments.First(), out team))
                {
                    arguments = arguments.Skip(1);
                }
            }

            var count = 1;

            if (arguments.Any())
            {
                if (int.TryParse(arguments.First(), out count))
                {
                    count = (int)MathHelper.Clamp(count, Constants.BOT_SPAWN_COUNT_MIN, Constants.BOT_SPAWN_COUNT_MAX);
                }
                else
                {
                    count = 1;
                }
            }

            for (var i = 0; i < count; i++)
            {
                BotManager.SpawnBot(botType, player: null, team: team, ignoreFullSpawner: true);
            }

            // Dont use the string name in case it just an index
            var bot = count > 1 ? " bots" : " bot";

            ScriptHelper.PrintMessage("Spawned " + count + " " + SharpHelper.EnumToString(botType) + bot + " to " + team);
        }
Ejemplo n.º 3
0
        private bool TurnIntoZombie()
        {
            if (Body.IsRemoved || Body.IsBurnedCorpse)
            {
                return(false);
            }

            var player     = Game.CreatePlayer(Body.GetWorldPosition());
            var zombieType = BotHelper.GetZombieType(Type);
            var oldProfile = Body.GetProfile();
            var oldWeapons = BotHelper.GetWeaponSet(Body); // TODO: test gun with lazer once gurt fixed https://www.mythologicinteractiveforums.com/viewtopic.php?f=31&t=4000

            ScriptHelper.LogDebug(Type, "->", zombieType);
            player.SetBotName(Body.Name); // NOTE: set right now so SpawnLine dialogue will show the bot name correctly

            var zombie     = BotManager.SpawnBot(zombieType, Faction, player, BotManager.GetBot(Body).InfectTeam);
            var zombieBody = zombie.Player;

            var modifiers = Body.GetModifiers();

            // Survivor has fake MaxHealth to have blood effect on the face
            if (Enum.GetName(typeof(BotType), BotManager.GetBot(Body).Type).StartsWith("Survivor"))
            {
                modifiers.CurrentHealth = modifiers.MaxHealth = 50;
            }
            else
            {
                modifiers.CurrentHealth = modifiers.MaxHealth * 0.75f;
            }

            zombieBody.SetModifiers(modifiers);
            zombieBody.SetProfile(BotHelper.ToZombieProfile(oldProfile));
            BotHelper.Equip(zombieBody, oldWeapons);

            Body.Remove();
            Body = zombieBody;
            Body.SetBotBehaivorActive(false);
            Body.AddCommand(new PlayerCommand(PlayerCommandType.StartCrouch));
            IsTurningIntoZombie = true;
            return(true);
        }
Ejemplo n.º 4
0
        public void OnStartup()
        {
            // How to create a bot
            // 1. Define bot type in BotType.cs
            // 2. Define bot profile in BotProfiles.cs
            // 3. Define bot weapon in BotWeapons.cs
            // 4. Define bot behavior in BotBehaviors.cs (optional)
            // 5. Define bot info in BotInfos.cs
            // 6. Define bot class in Bots/ and add it to BotFactory.cs for additional behaviors (optional)
            // 7. Define bot faction name in BotFaction.cs (optional)
            // 8. Define bot faction and sub-faction in BotFactionSets.cs

            //System.Diagnostics.Debugger.Break();

            BotManager.Initialize();

            if (Game.IsEditorTest)
            {
                var player    = Game.GetPlayers()[0];
                var modifiers = player.GetModifiers();

                modifiers.MaxHealth                 = 300;
                modifiers.CurrentHealth             = 300;
                modifiers.EnergyConsumptionModifier = .1f;
                modifiers.RunSpeedModifier          = 1.25f;
                modifiers.SprintSpeedModifier       = 1.25f;
                //modifiers.MeleeStunImmunity = 1;
                modifiers.InfiniteAmmo = 1;

                player.SetTeam(PlayerTeam.Team1);
                player.SetHitEffect(PlayerHitEffect.Metal);
                player.SetModifiers(modifiers);
                //player.GiveWeaponItem(WeaponItem.KNIFE);
                //player.GiveWeaponItem(WeaponItem.FLAREGUN);
                //player.GiveWeaponItem(WeaponItem.ASSAULT);
                player.GiveWeaponItem(WeaponItem.GRENADES);
                player.GiveWeaponItem(WeaponItem.STRENGTHBOOST);
            }
        }
Ejemplo n.º 5
0
 public void OnShutdown()
 {
     BotManager.OnShutdown();
 }