示例#1
0
文件: a_bots.cs 项目: Slvr11/horde
        public static bool spawnBot(int spawnLoc, bool isCrawler)
        {
            if ((!isCrawler && botPool.Count == 0) || (isCrawler && crawlerPool.Count == 0))
            {
                return(true);                                                                            //True so in case all 30 have spawned, don't error out
            }
            Entity bot;

            if (isCrawler)
            {
                bot = crawlerPool[0];
            }
            else
            {
                bot = botPool[0];
            }

            if (botSpawns.Count == 0)
            {
                Utilities.PrintToConsole("No bot spawns available! Please have at least one \"zombiespawn\" in your map file.");
                GSCFunctions.Announcement("^1No bot spawns available! Check console for details");
                return(false);
            }

            int randomInt = g_AIZ.rng.Next(20);

            bot.Origin = botSpawns[spawnLoc] + new Vector3(randomInt, randomInt, 0);
            bot.Angles = spawnAngles[spawnLoc];
            bot.Show();
            bot.ShowAllParts();

            if (isCrawler)
            {
                playAnimOnBot(bot, crawlerAnim_idle);
            }
            else
            {
                playAnimOnBot(bot, anim_idle);
            }

            bot.SetField("state", "idle");
            if (!isCrawler && bot.HasField("head"))
            {
                Entity botHead = bot.GetField <Entity>("head");
                botHead.Show();
                //Remove helmet
                botHead.HidePart("j_head_end");
                botHead.HidePart("j_helmet");
                botHead.HidePart("j_collar_rear");
                Entity headHitbox = bot.GetField <Entity>("headHitbox");
                headHitbox.SetCanDamage(true);
            }
            bot.SetField("isAlive", true);
            bot.SetField("isAttacking", false);
            int time = GSCFunctions.GetTime();

            bot.SetField("lastActiveTime", time);
            spawnedBots++;
            Entity botHitbox = bot.GetField <Entity>("hitbox");

            if (isCrawler)
            {
                botHitbox.SetField("currentHealth", crawlerHealth);
            }
            else
            {
                botHitbox.SetField("currentHealth", health);
            }
            botHitbox.SetField("damageTaken", 0);
            botHitbox.SetCanDamage(true);
            botHitbox.SetCanRadiusDamage(true);
            //botHitbox.Show();
            botHitbox.SetModel("com_plasticcase_dummy");

            botsInPlay.Add(bot);
            if (isCrawler)
            {
                crawlerPool.Remove(bot);
            }
            else
            {
                botPool.Remove(bot);
            }

            onBotUpdate();

            OnInterval(100, () => botAI(bot, botHitbox, isCrawler, false));

            //Check for waypoints on spawn once
            foreach (Entity v in h_mapEdit.waypoints)
            {
                Vector3 botHeadTag    = bot.GetTagOrigin("j_head");
                bool    waypointTrace = GSCFunctions.SightTracePassed(botHeadTag, v.Origin, false, botHitbox);//Check for waypoints
                if (waypointTrace)
                {
                    bot.SetField("currentWaypoint", v);//Set the first seen one as current
                    bot.SetField("visibleWaypoints", new Parameter(v.GetField <List <Entity> >("visiblePoints")));
                    break;
                }
            }

            return(true);
        }
示例#2
0
文件: a_bots.cs 项目: Slvr11/horde
        public static bool spawnBossBot(int SpawnLoc)
        {
            if (botSpawns.Count == 0)
            {
                Utilities.PrintToConsole("No bot spawns available! Please have at least one \"zombiespawn\" in your map file.");
                GSCFunctions.Announcement("^1No bot spawns available! Check console for details");
                return(false);
            }

            Entity bot = GSCFunctions.Spawn("script_model", botSpawns[SpawnLoc]);

            spawnedBots++;
            bot.Angles = spawnAngles[SpawnLoc];
            bot.SetModel("mp_fullbody_opforce_juggernaut");
            playAnimOnBot(bot, anim_idle);
            bot.SetField("isAlive", true);
            botsInPlay.Add(bot);
            Entity botHitbox = GSCFunctions.Spawn("script_model", bot.Origin + new Vector3(0, 0, 30));

            botHitbox.SetModel("com_plasticcase_trap_friendly");
            //botHitbox.CloneBrushModelToScriptModel(_airdropCollision);
            botHitbox.Angles = new Vector3(90, bot.Angles.Y, 0);
            //botHitbox.Solid();
            botHitbox.SetCanDamage(true);
            botHitbox.SetCanRadiusDamage(true);
            botHitbox.LinkTo(bot, "j_mainroot");
            botHitbox.Hide();
            botHitbox.SetField("currentHealth", bossHealth);
            botHitbox.SetField("damageTaken", 0);
            botHitbox.SetField("parent", bot);
            botHitbox.SetField("isBoss", true);
            bot.SetField("hitbox", botHitbox);
            bot.SetField("state", "idle");
            bot.SetField("isAttacking", false);
            bot.SetField("currentWaypoint", bot);
            bot.SetField("isOnCompass", false);
            bot.SetField("primedForNuke", false);
            bot.SetField("lastActiveTime", 0); //Bosses won't die from time
            b_roundSystem.checkForCompass();   //Check every spawn so when the last bot spawns, he activates the compass for all

            onBotUpdate();

            c_bonusDrops.onNuke += () => killBotOnNuke(bot, false, true);

            AfterDelay(50, () => OnInterval(100, () => botAI(bot, botHitbox, false, true)));//wait a frame to let the bot spawn

            //Delay to allow AI to intitalize
            AfterDelay(100, () => botHitbox.OnNotify("damage", (entity, damage, attacker, direction_vec, point, meansOfDeath, modelName, partName, tagName, iDFlags, weapon) => onBotDamage(entity, damage, attacker, direction_vec, point, meansOfDeath, modelName, partName, tagName, iDFlags, weapon, false, true)));

            //Check for waypoints on spawn once
            foreach (Entity v in h_mapEdit.waypoints)
            {
                Vector3 botHeadTag    = bot.GetTagOrigin("j_head");
                bool    waypointTrace = GSCFunctions.SightTracePassed(botHeadTag, v.Origin, false, botHitbox);//Check for waypoints
                if (waypointTrace)
                {
                    bot.SetField("currentWaypoint", v);//Set the first seen one as current
                    bot.SetField("visibleWaypoints", new Parameter(v.GetField <List <Entity> >("visiblePoints")));
                    break;
                }
            }

            return(true);
        }