예제 #1
0
            private bool TurnIntoZombie()
            {
                if (Body.IsRemoved || Body.IsBurnedCorpse)
                {
                    return(false);
                }

                var zombieBody = Game.CreatePlayer(Body.GetWorldPosition());

                if (rnd.Next(0, 100) < 10)
                {
                    Game.CreateDialogue("Brainzz", zombieBody);
                }
                zombieBody.SetBotBehaviorSet(BotBehaviorSet.GetBotBehaviorPredefinedSet(GetZombieType(Body)));
                zombieBody.SetTeam(ZombieTeam);

                var modifiers = Body.GetModifiers();

                modifiers.RunSpeedModifier    -= 0.15f;
                modifiers.SprintSpeedModifier -= 0.15f;
                modifiers.CurrentHealth        = modifiers.MaxHealth * 0.75f;
                zombieBody.SetModifiers(modifiers);

                var profile = Body.GetProfile();

                zombieBody.SetProfile(ToZombieProfile(profile));
                zombieBody.SetBotName(Body.Name);

                Body.Remove();
                Body = zombieBody;
                Body.SetBotBehaivorActive(false);
                Body.AddCommand(new PlayerCommand(PlayerCommandType.StartCrouch));
                IsTurningIntoZombie = true;
                return(true);
            }
예제 #2
0
        public void OnStartup()
        {
            var me = Game.GetPlayers()[0];

            me.GiveWeaponItem(WeaponItem.PISTOL);
            me.GiveWeaponItem(WeaponItem.M60);
            var mod = me.GetModifiers();

            mod.MeleeStunImmunity = 1;
            me.SetModifiers(mod);

            Game.RunCommand("ia 1");
            Game.RunCommand("ih 1");

            foreach (var player in Game.GetPlayers())
            {
                if (player == me)
                {
                    continue;
                }

                var bot = Game.CreatePlayer(player.GetWorldPosition());
                bot.SetBotName("bot " + rnd.Next(0, 1000));
                bot.SetBotBehaviorSet(BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.BotD));
                bot.SetBotBehaviorActive(true);
                player.Remove();
            }


            Events.UpdateCallback.Start(OnUpdate);
            Events.ProjectileCreatedCallback.Start(OnProjectileCreated);
            Events.ProjectileHitCallback.Start(OnProjectileHit);
        }
예제 #3
0
        private void TryToFlee()
        {
            m_targetLocation = null;

            foreach (var spawner in Game.GetObjectsByName("SpawnPlayer"))
            {
                var safeArea           = SafeArea(spawner.GetWorldPosition());
                var enemiesNearSpawner = Game.GetObjectsByArea <IPlayer>(safeArea).Any(p => !ScriptHelper.SameTeam(Player, p));

                if (!enemiesNearSpawner)
                {
                    var pathNode = Game.GetSingleObjectByArea <IObjectPathNode>(spawner.GetAABB(), PhysicsLayer.Background);
                    if (pathNode == null)
                    {
                        continue;
                    }

                    Game.DrawArea(safeArea, Color.Magenta);
                    if (m_targetLocation == null)
                    {
                        m_targetLocation = pathNode;
                    }
                    else if (m_targetLocation != null && Vector2.DistanceSquared(m_targetLocation.GetWorldPosition(), Actor.Position)
                             > Vector2.DistanceSquared(pathNode.GetWorldPosition(), Actor.Position))
                    {
                        m_targetLocation = pathNode;
                    }
                }
            }

            if (m_targetLocation != null)
            {
                var runningBehavior = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.FunnymanRunning);

                runningBehavior.GuardRange = 1f;
                runningBehavior.ChaseRange = 1f;
                Player.SetBotBehaviorSet(runningBehavior);
                Actor.SetModifiers(RunningModifiers);
                Player.SetGuardTarget(m_targetLocation);
                ChangeState(State.Fleeing);
            }
        }
예제 #4
0
        private void SpawnBadSanta(Vector2 position)
        {
            var player = Game.CreatePlayer(position);

            player.SetModifiers(new PlayerModifiers()
            {
                MaxHealth     = 200,
                CurrentHealth = 200,
                ExplosionDamageTakenModifier = 0.5f,
                MeleeForceModifier           = 1.5f,
                SizeModifier = 1.1f,
                InfiniteAmmo = 1,
            });
            player.SetProfile(new IProfile()
            {
                Name       = "Bad Santa",
                Accesory   = new IProfileClothingItem("SantaMask", "ClothingLightGray", "ClothingLightGray", ""),
                ChestOver  = new IProfileClothingItem("Coat", "ClothingRed", "ClothingLightGray", ""),
                ChestUnder = new IProfileClothingItem("SleevelessShirt", "ClothingLightGray", "ClothingLightGray", ""),
                Feet       = new IProfileClothingItem("BootsBlack", "ClothingBrown", "ClothingLightGray", ""),
                Gender     = Gender.Male,
                Hands      = new IProfileClothingItem("SafetyGlovesBlack", "ClothingGray", "ClothingLightGray", ""),
                Head       = new IProfileClothingItem("SantaHat", "ClothingRed", "ClothingLightGray", ""),
                Legs       = new IProfileClothingItem("Pants", "ClothingRed", "ClothingLightGray", ""),
                Skin       = new IProfileClothingItem("Tattoos", "Skin3", "ClothingPink", ""),
                Waist      = new IProfileClothingItem("Belt", "ClothingDarkRed", "ClothingLightYellow", ""),
            });
            player.SetBotName("Bad Santa");

            player.SetBotBehaviorSet(BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.ChallengeA));
            player.SetBotBehaviorActive(true);

            player.SetTeam(PlayerTeam.Independent);

            player.GiveWeaponItem(WeaponItem.KNIFE);
            player.GiveWeaponItem(WeaponItem.M60);
            player.GiveWeaponItem(WeaponItem.UZI);

            Game.CreateDialogue("Ho ho ho!", new Color(128, 32, 32), player);
        }
예제 #5
0
        public static BotBehaviorSet GetBehaviorSet(BotAI botAI)
        {
            var botBehaviorSet = new BotBehaviorSet()
            {
                MeleeActions                  = BotMeleeActions.Default,
                MeleeActionsWhenHit           = BotMeleeActions.DefaultWhenHit,
                MeleeActionsWhenEnraged       = BotMeleeActions.DefaultWhenEnraged,
                MeleeActionsWhenEnragedAndHit = BotMeleeActions.DefaultWhenEnragedAndHit,
                ChaseRange = 44f,
                GuardRange = 40f,
            };

            switch (botAI)
            {
                #region Debug
            case BotAI.Debug:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.BotD);
                botBehaviorSet.RangedWeaponBurstTimeMin  = 5000;
                botBehaviorSet.RangedWeaponBurstTimeMax  = 5000;
                botBehaviorSet.RangedWeaponBurstPauseMin = 0;
                botBehaviorSet.RangedWeaponBurstPauseMax = 0;
                break;
            }
                #endregion

                #region Easy
            case BotAI.Easy:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.BotD);
                break;
            }
                #endregion

                #region Normal
            case BotAI.Normal:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.BotC);
                break;
            }
                #endregion

                #region Hard
            case BotAI.Hard:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.BotB);
                break;
            }
                #endregion

                #region Expert
            case BotAI.Expert:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.BotA);
                break;
            }
                #endregion

                #region Hacker
            case BotAI.Hacker:
            {
                botBehaviorSet.NavigationMode                     = BotBehaviorNavigationMode.PathFinding;
                botBehaviorSet.MeleeMode                          = BotBehaviorMeleeMode.Default;
                botBehaviorSet.EliminateEnemies                   = true;
                botBehaviorSet.SearchForItems                     = true;
                botBehaviorSet.OffensiveEnrageLevel               = 0.8f;
                botBehaviorSet.NavigationRandomPausesLevel        = 0.1f;
                botBehaviorSet.DefensiveRollFireLevel             = 0.95f;
                botBehaviorSet.DefensiveAvoidProjectilesLevel     = 0.7f;
                botBehaviorSet.OffensiveClimbingLevel             = 0.7f;
                botBehaviorSet.OffensiveSprintLevel               = 0.6f;
                botBehaviorSet.OffensiveDiveLevel                 = 0.6f;
                botBehaviorSet.CounterOutOfRangeMeleeAttacksLevel = 0.9f;
                botBehaviorSet.ChokePointPlayerCountThreshold     = 1;
                botBehaviorSet.ChokePointValue                    = 150f;
                botBehaviorSet.MeleeWaitTimeLimitMin              = 100f;
                botBehaviorSet.MeleeWaitTimeLimitMax              = 200f;
                botBehaviorSet.MeleeUsage                         = true;
                botBehaviorSet.SetMeleeActionsToExpert();
                botBehaviorSet.MeleeWeaponUsage                      = true;
                botBehaviorSet.RangedWeaponUsage                     = true;
                botBehaviorSet.RangedWeaponAccuracy                  = 0.85f;
                botBehaviorSet.RangedWeaponAimShootDelayMin          = 50f;
                botBehaviorSet.RangedWeaponAimShootDelayMax          = 200f;
                botBehaviorSet.RangedWeaponHipFireAimShootDelayMin   = 50f;
                botBehaviorSet.RangedWeaponHipFireAimShootDelayMax   = 50f;
                botBehaviorSet.RangedWeaponBurstTimeMin              = 400f;
                botBehaviorSet.RangedWeaponBurstTimeMax              = 800f;
                botBehaviorSet.RangedWeaponBurstPauseMin             = 400f;
                botBehaviorSet.RangedWeaponBurstPauseMax             = 800f;
                botBehaviorSet.RangedWeaponPrecisionInterpolateTime  = 800f;
                botBehaviorSet.RangedWeaponPrecisionAccuracy         = 0.95f;
                botBehaviorSet.RangedWeaponPrecisionAimShootDelayMin = 25f;
                botBehaviorSet.RangedWeaponPrecisionAimShootDelayMax = 50f;
                botBehaviorSet.RangedWeaponPrecisionBurstTimeMin     = 800f;
                botBehaviorSet.RangedWeaponPrecisionBurstTimeMax     = 1600f;
                botBehaviorSet.RangedWeaponPrecisionBurstPauseMin    = 100f;
                botBehaviorSet.RangedWeaponPrecisionBurstPauseMax    = 200f;
                break;
            }
                #endregion

                #region MeleeExpert
            case BotAI.MeleeExpert:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.MeleeB);
                botBehaviorSet.CounterOutOfRangeMeleeAttacksLevel = 0.9f;
                botBehaviorSet.MeleeWaitTimeLimitMin   = 600f;
                botBehaviorSet.MeleeWaitTimeLimitMax   = 800f;
                botBehaviorSet.MeleeUsage              = true;
                botBehaviorSet.MeleeWeaponUsage        = true;
                botBehaviorSet.MeleeWeaponUseFullRange = true;
                break;
            }
                #endregion

                #region MeleeHard
            case BotAI.MeleeHard:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.MeleeB);
                botBehaviorSet.CounterOutOfRangeMeleeAttacksLevel = 0.75f;
                botBehaviorSet.MeleeWaitTimeLimitMin   = 800f;
                botBehaviorSet.MeleeWaitTimeLimitMax   = 1000f;
                botBehaviorSet.MeleeUsage              = true;
                botBehaviorSet.MeleeWeaponUsage        = true;
                botBehaviorSet.MeleeWeaponUseFullRange = false;
                break;
            }
                #endregion

                #region Ninja == BotAI.MeleeExpert + more offensive melee tactic
            case BotAI.Ninja:
            {
                botBehaviorSet = Rage(botBehaviorSet);
                botBehaviorSet = VeryDefensive(botBehaviorSet);

                botBehaviorSet.MeleeUsage              = true;
                botBehaviorSet.MeleeWeaponUsage        = true;
                botBehaviorSet.MeleeWeaponUseFullRange = true;
                botBehaviorSet.SearchForItems          = true;
                botBehaviorSet.SearchItems             = SearchItems.Melee | SearchItems.Throwable;

                botBehaviorSet.OffensiveEnrageLevel = 0.5f;
                botBehaviorSet.OffensiveDiveLevel   = 0.1f;
                break;
            }
                #endregion

                #region RangeExpert
            case BotAI.RangeExpert:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.RangedA);
                botBehaviorSet.RangedWeaponAccuracy                 = 0.85f;
                botBehaviorSet.RangedWeaponAimShootDelayMin         = 600f;
                botBehaviorSet.RangedWeaponPrecisionInterpolateTime = 2000f;
                botBehaviorSet.RangedWeaponPrecisionAccuracy        = 0.95f;
                break;
            }
                #endregion

                #region RangeHard
            case BotAI.RangeHard:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.RangedA);
                botBehaviorSet.RangedWeaponAccuracy                 = 0.75f;
                botBehaviorSet.RangedWeaponAimShootDelayMin         = 600f;
                botBehaviorSet.RangedWeaponPrecisionInterpolateTime = 2000f;
                botBehaviorSet.RangedWeaponPrecisionAccuracy        = 0.9f;
                break;
            }
                #endregion

                #region Sniper == BotAI.RangeExpert + Defensive
            case BotAI.Sniper:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.RangedA);
                botBehaviorSet.RangedWeaponMode                     = BotBehaviorRangedWeaponMode.ManualAim;
                botBehaviorSet.RangedWeaponAccuracy                 = 0.85f;
                botBehaviorSet.RangedWeaponAimShootDelayMin         = 600f;
                botBehaviorSet.RangedWeaponPrecisionInterpolateTime = 2000f;
                botBehaviorSet.RangedWeaponPrecisionAccuracy        = 0.95f;

                botBehaviorSet            = VeryDefensive(botBehaviorSet);
                botBehaviorSet            = VeryInoffensive(botBehaviorSet);
                botBehaviorSet.TeamLineUp = false;
                break;
            }
                #endregion

                #region Grunt
            case BotAI.Grunt:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.Grunt);

                // Taken from PredefinedAIType.BotB, PredefinedAIType.Grunt is too slow in shooting
                botBehaviorSet.RangedWeaponAimShootDelayMin        = 200f;
                botBehaviorSet.RangedWeaponAimShootDelayMax        = 600f;
                botBehaviorSet.RangedWeaponHipFireAimShootDelayMin = 200f;
                botBehaviorSet.RangedWeaponHipFireAimShootDelayMax = 600f;
                botBehaviorSet.RangedWeaponBurstTimeMin            = 400f;
                botBehaviorSet.RangedWeaponBurstTimeMax            = 800f;
                botBehaviorSet.RangedWeaponBurstPauseMin           = 400f;
                botBehaviorSet.RangedWeaponBurstPauseMax           = 800f;
                break;
            }
                #endregion

                #region Hulk
            case BotAI.Hulk:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.Hulk);
                botBehaviorSet.SetMeleeActionsAll(HulkMeleeActions);
                break;
            }
                #endregion

                #region RagingHulk
            case BotAI.RagingHulk:
            {
                botBehaviorSet = GetBehaviorSet(BotAI.Hulk);
                botBehaviorSet = Rage(botBehaviorSet);
                botBehaviorSet.SetMeleeActionsAll(new BotMeleeActions()
                    {
                        Attack      = (ushort)4,
                        AttackCombo = (ushort)20,
                        Block       = (ushort)1,
                        Kick        = (ushort)4,
                        Jump        = (ushort)1,
                        Wait        = (ushort)5,
                        Grab        = (ushort)12
                    });
                break;
            }
                #endregion

                #region Meatgrinder
            case BotAI.Meatgrinder:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.Meatgrinder);
                break;
            }
                #endregion

                #region Assassin
            case BotAI.AssassinMelee:
            {
                botBehaviorSet = GetBehaviorSet(BotAI.MeleeHard);
                botBehaviorSet = Jogger(botBehaviorSet);
                break;
            }

            case BotAI.AssassinRange:
            {
                botBehaviorSet = GetBehaviorSet(BotAI.RangeHard);
                botBehaviorSet = Jogger(botBehaviorSet);
                break;
            }
                #endregion

                #region BabyBear
            case BotAI.Babybear:
            {
                botBehaviorSet = GetBehaviorSet(BotAI.Easy);
                botBehaviorSet.RangedWeaponUsage      = false;
                botBehaviorSet.SearchForItems         = false;
                botBehaviorSet.OffensiveClimbingLevel = 0.9f;
                botBehaviorSet.OffensiveSprintLevel   = 0.85f;
                botBehaviorSet.GuardRange             = 16;
                botBehaviorSet.ChaseRange             = 16;
                break;
            }
                #endregion

                #region Cowboy
            case BotAI.Cowboy:
            {
                botBehaviorSet = GetBehaviorSet(BotAI.Grunt);
                botBehaviorSet = TriggerHappy(botBehaviorSet);
                break;
            }
                #endregion

                #region Kingpin
            case BotAI.Kingpin:
            {
                botBehaviorSet = GetBehaviorSet(BotAI.Hard);
                botBehaviorSet.SetMeleeActionsAll(HulkMeleeActions);
                break;
            }
                #endregion

                #region Sheriff
            case BotAI.Sheriff:
            {
                botBehaviorSet = GetBehaviorSet(BotAI.Hard);
                botBehaviorSet = TriggerHappy(botBehaviorSet);
                break;
            }
                #endregion

                #region Soldier
            case BotAI.Soldier:
            {
                botBehaviorSet = GetBehaviorSet(BotAI.Hard);
                botBehaviorSet = Defensive(botBehaviorSet);
                break;
            }
                #endregion

                #region ZombieSlow
            case BotAI.ZombieSlow:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.ZombieA);
                break;
            }
                #endregion

                #region ZombieFast
            case BotAI.ZombieFast:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.ZombieB);
                break;
            }
                #endregion

                #region ZombieHulk
            case BotAI.ZombieHulk:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.Hulk);
                botBehaviorSet.AttackDeadEnemies = true;
                botBehaviorSet.SearchForItems    = false;
                botBehaviorSet.MeleeWeaponUsage  = false;
                botBehaviorSet.RangedWeaponUsage = false;
                botBehaviorSet.PowerupUsage      = false;
                botBehaviorSet.ChokePointValue   = 32f;
                botBehaviorSet.ChokePointPlayerCountThreshold     = 5;
                botBehaviorSet.DefensiveRollFireLevel             = 0.1f;
                botBehaviorSet.OffensiveDiveLevel                 = 0f;
                botBehaviorSet.CounterOutOfRangeMeleeAttacksLevel = 0f;
                break;
            }
                #endregion

                #region ZombieFighter
            case BotAI.ZombieFighter:
            {
                botBehaviorSet = BotBehaviorSet.GetBotBehaviorPredefinedSet(PredefinedAIType.MeleeB);
                botBehaviorSet.AttackDeadEnemies = true;
                botBehaviorSet.SearchForItems    = false;
                botBehaviorSet.MeleeWeaponUsage  = false;
                botBehaviorSet.RangedWeaponUsage = false;
                botBehaviorSet.PowerupUsage      = false;
                botBehaviorSet.ChokePointValue   = 32f;
                botBehaviorSet.ChokePointPlayerCountThreshold     = 5;
                botBehaviorSet.DefensiveRollFireLevel             = 0.1f;
                botBehaviorSet.OffensiveDiveLevel                 = 0f;
                botBehaviorSet.CounterOutOfRangeMeleeAttacksLevel = 0f;
                botBehaviorSet.RocketRideProficiency              = .8f;
                break;
            }
                #endregion

                #region default
            default:
            {
                botBehaviorSet.NavigationMode   = BotBehaviorNavigationMode.None;
                botBehaviorSet.MeleeMode        = BotBehaviorMeleeMode.None;
                botBehaviorSet.EliminateEnemies = false;
                botBehaviorSet.SearchForItems   = false;
                break;
            }
                #endregion
            }

            botBehaviorSet.SearchForItems = true;
            botBehaviorSet.SearchItems    = SearchItems.None; // Disable SearchItems by setting to None

            return(botBehaviorSet);
        }