コード例 #1
0
 public void Use(Player p, string[] args)
 {
     if (args.Length < 1)
     {
         p.SendMessage("You must specify a name!");
         return;
     }
     Random Random = new Random();
     string margs = ArrayToString(args);
     margs = margs.Replace('%', '&');
     Bot TemporaryPlayer = new Bot(margs, p.Pos, p.Rot, p.Level, true, true, true);
     TemporaryPlayer.Player.Level.ExtraData.Add("Bot" + Random.Next(0, 9999999), margs + " " + TemporaryPlayer.FollowPlayers +  //TODO - Random INT so the dictionary doesnt clash - this should be fixed
         " " + TemporaryPlayer.Player.Pos.x + " " + TemporaryPlayer.Player.Pos.y + " " + TemporaryPlayer.Player.Pos.z + " "
         + TemporaryPlayer.Player.Rot[0] + " " + TemporaryPlayer.Player.Rot[1]); //Add bot to level metadata
                                                                                 //This enables cross server bot transfer
                                                                                 //And returns when level is loaded
     p.SendMessage("Spawned " + ArrayToString(args) + Server.DefaultColor + "!");
 }
コード例 #2
0
ファイル: CmdBot.cs プロジェクト: headdetect/MCForge6-Vanilla
        public void Use(Player p, string[] args)
        {
            if (args.Length < 2)
            {
                p.SendMessage("You must specify an option and a name!");
                return;
            }
            Random Random = new Random();
            if (args[0].ToLower() == "add")
            {
                List<string> fargs = new List<string>();
                int l = 0;
                foreach (string s in args) {
                    if (l > 0)
                        fargs.Add(s);
                    l++;
                }
                string margs = ArrayToString(fargs.ToArray());
                margs = margs.Replace('%', '&');
                Bot TemporaryPlayer = new Bot(margs, p.Pos, new byte[2] { (byte)p.Rot.x, (byte)p.Rot.z }, p.Level, false, false, false);
                TemporaryPlayer.Player.Level.ExtraData.Add("Bot" + Random.Next(0, 9999999), margs + " " + TemporaryPlayer.FollowPlayers + " " + TemporaryPlayer.BreakBlocks + " " + TemporaryPlayer.Jumping +
                    " " + TemporaryPlayer.Player.Pos.x + " " + TemporaryPlayer.Player.Pos.y + " " + TemporaryPlayer.Player.Pos.z + " "
                    + TemporaryPlayer.Player.Rot.x + " " + TemporaryPlayer.Player.Rot.z); //Add bot to level metadata
                                                                                            //This enables cross server bot transfer
                                                                                            //And returns when level is loaded
                p.SendMessage("Spawned " + ArrayToString(fargs.ToArray()) + Server.DefaultColor + "!");
            }
            else if (args[0].ToLower() == "remove")
            {
                List<string> fargs = new List<string>();
                int l = 0;
                foreach (string s in args)
                {
                    if (l > 0)
                        fargs.Add(s);
                    l++;
                }
                string margs = ArrayToString(fargs.ToArray());
                margs = margs.Replace('%', '&');
                bool hitBot = false;
                foreach (Bot b in Server.Bots.ToArray())
                {
                    if (b.Player.Username.ToLower() == margs.ToLower() &&
                        b.Player.Level == p.Level)
                    {
                        hitBot = true;
                        b.Player.GlobalDie();
                        Server.Bots.Remove(b);
                    }
                }
                List<string> tempArray = new List<string>();
                foreach (var b in p.Level.ExtraData)
                {
                    if (b.Value.ToString().ToLower().Split(' ')[0].Equals(margs.ToLower()))
                    {
                        tempArray.Add(b.Key.ToString());
                    }
                }
                foreach (string s in tempArray)
                {
                    hitBot = true;
                    p.Level.ExtraData.Remove(s);
                }
                if (hitBot)
                    p.SendMessage("Removed " + ArrayToString(fargs.ToArray()) + Server.DefaultColor + "!");
                else
                    p.SendMessage("Could not find " + ArrayToString(fargs.ToArray()) + Server.DefaultColor + "!");
            }
            else if (args[0].ToLower() == "summon")
            {
                List<string> fargs = new List<string>();
                int l = 0;
                foreach (string s in args)
                {
                    if (l > 0)
                        fargs.Add(s);
                    l++;
                }
                string margs = ArrayToString(fargs.ToArray());
                margs = margs.Replace('%', '&');
                bool hitBot = false;
                foreach (Bot b in Server.Bots.ToArray())
                {
                    if (b.Player.Username.ToLower() == margs.ToLower() &&
                        b.Player.Level == p.Level)
                    {
                        hitBot = true;
                        b.Player.Pos = p.Pos;
                    }
                }
                if (hitBot)
                    p.SendMessage("Summoned " + ArrayToString(fargs.ToArray()) + Server.DefaultColor + "!");
                else
                    p.SendMessage("Could not find " + ArrayToString(fargs.ToArray()) + Server.DefaultColor + "!");
            }
            else if (args[0].ToLower() == "ai")
            {
                List<string> fargs = new List<string>();
                int l = 0;
                foreach (string s in args)
                {
                    if (l > 0)
                        fargs.Add(s);
                    l++;
                }
                string margs = ArrayToString(fargs.ToArray());
                margs = margs.Replace('%', '&');
                string[] blargs = margs.Split('"');
                if (blargs.Length != 3)
                {
                    p.SendMessage("You need to use \"'s in your command!");
                    return;
                }
                foreach (string s in blargs) {
                    s.Replace("\"", "");
                }
                string FoundPlayer = blargs[1];
                string AI = "";
                try
                {
                    AI = blargs[2].Remove(0, 1);
                }
                catch {
                    p.SendMessage("You need to fill out the entire command!");
                    return;
                }
                bool HitBot = false;

                Bot Bot = null;

                foreach (Bot b in Server.Bots.ToArray())
                {
                    if (b.Player.Username.ToLower() == FoundPlayer.ToLower())
                    {
                        switch (AI)
                        {
                            case "follow":
                                b.FollowPlayers = !b.FollowPlayers;
                                HitBot = true;
                                Bot = b;
                                break;
                            case "break":
                                b.BreakBlocks = !b.BreakBlocks;
                                HitBot = true;
                                Bot = b;
                                break;
                            case "jump":
                                b.Jumping = !b.Jumping;
                                HitBot = true;
                                Bot = b;
                                break;
                        }
                    }
                }

                if (HitBot)
                    p.SendMessage("Changed " + FoundPlayer + "'s AI!");
                else
                {
                    p.SendMessage("Couldn't find " + FoundPlayer + " or change the AI!");
                    return;
                }

                List<string> tempArray = new List<string>();
                foreach (var b in p.Level.ExtraData)
                {
                    if (b.Value.ToString().ToLower().Split(' ')[0].Equals(margs.ToLower()))
                    {
                        tempArray.Add(b.Key.ToString());
                    }
                }
                foreach (string s in tempArray)
                {
                    p.Level.ExtraData.Remove(s);
                }

                Bot.Player.Level.ExtraData.Add("Bot" + Random.Next(0, 9999999), margs + " " + Bot.FollowPlayers + " " + Bot.BreakBlocks +
                    " " + Bot.Player.Pos.x + " " + Bot.Player.Pos.y + " " + Bot.Player.Pos.z + " "
                    + Bot.Player.Rot.x + " " + Bot.Player.Rot.z);
            }
        }
コード例 #3
0
ファイル: Level.cs プロジェクト: headdetect/MCForge6-Vanilla
 /// <summary>
 /// Handles the extra data for the level
 /// </summary>
 public void HandleMetaData()
 {
     if (ExtraData.Count > 0)
     {
         try
         {
             foreach (var pair in ExtraData)
             {
                 if (pair.Key.ToString().StartsWith("Bot")) //Load bots
                 {
                     string[] StringSplit = pair.Value.ToString().Split(' ');
                     if (StringSplit.Length == 9)
                     {
                         ushort x = Convert.ToUInt16(StringSplit[4]);
                         ushort y = Convert.ToUInt16(StringSplit[5]);
                         ushort z = Convert.ToUInt16(StringSplit[6]);
                         Bot TemporaryBot = new Bot(StringSplit[0],
                             new Vector3S(x, z, y),
                             new byte[] { Convert.ToByte(StringSplit[7]), Convert.ToByte(StringSplit[8]) }, this,
                             Convert.ToBoolean(StringSplit[1]), Convert.ToBoolean(StringSplit[2]), Convert.ToBoolean(StringSplit[3]));
                     }
                 }
             }
         }
         catch (Exception e) { Logger.LogError(e); }
     }
 }
コード例 #4
0
 public static void RainBots(Level Level)
 {
     for (int i = 0; i < Random.Next(5,9); i++)
     {
         short x = (short)Random.Next(32, Level.CWMap.Size.x * 32);
         short y = (short)((Level.CWMap.Size.y - 4) * 32);
         short z = (short)Random.Next(32, Level.CWMap.Size.z * 32);
         Bot ZombieBot = new Bot("UndeaadBot" + i, new Vector3S(x, z, y), new byte[] { 0, 0 }, Level, false, false, false);
         ZombieBot.Player.DisplayName = "";
         ZombieBot.Player.IsHeadFlipped = true;
         ZombieBot.FollowPlayers = true;
         ZombieBot.BreakBlocks = true;
         ZombieBot.Jumping = true;
     }
 }
コード例 #5
0
ファイル: Bot.cs プロジェクト: Maicke98/MCForge-Vanilla
 protected void SpawnThisBotToOtherPlayers(Bot z)
 {
     Server.ForeachPlayer(delegate(Player p)
     {
         if (p != z.Player && p.Level == z.Player.Level)
             p.SendSpawn(z.Player);
     });
 }
コード例 #6
0
ファイル: Bot.cs プロジェクト: headdetect/MCForge6-Vanilla
 public static BreadCrumb Pathfind(Bot Bot, Vector3S ClosestLocation)
 {
     return PathFinder.FindPath(Bot.Player.Level, Bot.LevelMap, new Point3D((Bot.Player.Pos.x / 32), (Bot.Player.Pos.y / 32), (Bot.Player.Pos.z / 32)),
         new Point3D((ClosestLocation.x / 32), (ClosestLocation.y / 32), (ClosestLocation.z / 32)));
 }
コード例 #7
0
ファイル: Bot.cs プロジェクト: ninedrafted/MCForge7-Vanilla
 public static BreadCrumb Pathfind(Bot Bot, Vector3S ClosestLocation)
 {
     return(PathFinder.FindPath(Bot.Player.Level, Bot.LevelMap, new Point3D((Bot.Player.Pos.x / 32), (Bot.Player.Pos.y / 32), (Bot.Player.Pos.z / 32)),
                                new Point3D((ClosestLocation.x / 32), (ClosestLocation.y / 32), (ClosestLocation.z / 32))));
 }