Esempio n. 1
0
        static Vec3U16 MissileTarget(WeaponArgs args)
        {
            Player p = args.player;

            args.start = MakePos(p);
            args.dir   = DirUtils.GetDirVector(p.Rot.RotY, p.Rot.HeadX);
            int i;

            for (i = 1; ; i++)
            {
                Vec3U16 target = args.PosAt(i);
                BlockID block  = p.level.GetBlock(target.X, target.Y, target.Z);
                if (block == Block.Invalid)
                {
                    break;
                }

                if (block != Block.Air && !args.allBlocks.Contains(target) && HandlesHitBlock(p, block, args.weaponType, target, false))
                {
                    break;
                }

                Player hit = GetPlayer(p, target, true);
                if (hit != null)
                {
                    return(MakePos(hit));
                }
            }
            return(args.PosAt(i - 1));
        }
Esempio n. 2
0
        Vec3U16 MissileTarget(MissileData args)
        {
            args.start = (Vec3U16)p.Pos.BlockCoords;
            args.dir   = DirUtils.GetDirVector(p.Rot.RotY, p.Rot.HeadX);
            int i;

            for (i = 1; ; i++)
            {
                Vec3U16 target = args.PosAt(i);
                BlockID block  = p.level.GetBlock(target.X, target.Y, target.Z);

                if (block == Block.Invalid)
                {
                    break;
                }
                if (block != Block.Air && !args.all.Contains(target))
                {
                    break;
                }

                Player hit = PlayerAt(p, target, true);
                if (hit != null)
                {
                    return((Vec3U16)hit.Pos.BlockCoords);
                }
            }
            return(args.PosAt(i - 1));
        }
Esempio n. 3
0
        static void BlockChangingCallback(Player p, ushort x, ushort y, ushort z, BlockID block, bool placing, ref bool cancel)
        {
            Weapon weapon = p.weapon;

            if (weapon == null)
            {
                return;
            }

            // Revert block back since client assumes changes always succeeds
            p.RevertBlock(x, y, z);
            cancel = true;

            // Defer to player click handler if PlayerClick supported
            if (weapon.aimer == null)
            {
                return;
            }

            if (!p.level.Config.Guns)
            {
                weapon.Disable(); return;
            }
            if (!CommandParser.IsBlockAllowed(p, "use", block))
            {
                return;
            }

            Vec3F32 dir = DirUtils.GetDirVector(p.Rot.RotY, p.Rot.HeadX);

            weapon.OnActivated(dir, block);
        }
Esempio n. 4
0
        public override void ExecuteLeft(Player p)
        {
            byte targetkick = (byte)((p.rot[0] - 32) % 256);
            var  targetdir  = DirUtils.GetDirVector(targetkick, p.rot[1]);

            PlayerHandlers.KickBall(p, (float)(targetdir.X * 0.5), 0, (float)(targetdir.Z * 0.5), false);
        }
Esempio n. 5
0
        public static void KickBall(Player p, ushort Yaw, ushort Pitch)
        {
            Yaw   = (byte)(Yaw >> 8);
            Pitch = (byte)(Pitch >> 8);
            var Dir = DirUtils.GetDirVector((byte)Yaw, (byte)Pitch);

            KickBall(p, Dir.X, Dir.Y, Dir.Z);
        }
Esempio n. 6
0
        public override void ExecuteRight(Player p)
        {
            var dir = DirUtils.GetDirVector(p.rot[0], p.rot[1]);

            PlayerHandlers.KickBall(p, (float)(dir.X * -0.1), 0, (float)(dir.Z * -0.3));
            Thread.Sleep(250);
            PlayerHandlers.KickBall(p, (float)(dir.X * 0.5), 0, (float)(dir.Z * 0.5));
        }
        void Step(PlayerBot bot)
        {
            bot.TargetPos = bot.Pos;
            bot.movement  = true;
            Vec3F32 dir = DirUtils.GetDirVector(bot.Rot.RotY, 0);

            bot.TargetPos.X = bot.Pos.X + (int)(dir.X * bot.movementSpeed);
            bot.TargetPos.Z = bot.Pos.Z + (int)(dir.Z * bot.movementSpeed);
        }
Esempio n. 8
0
        public override void ExecuteLeft(Player p)
        {
            byte first     = (byte)((p.rot[0] + 90) % 256);
            var  firstdir  = DirUtils.GetDirVector(first, p.rot[1]);
            byte second    = (byte)((p.rot[0] - 60) % 256);
            var  seconddir = DirUtils.GetDirVector(second, p.rot[1]);

            PlayerHandlers.KickBall(p, (float)(firstdir.X * 0.1), 0, (float)(firstdir.Z * 0.1));
            Thread.Sleep(500);
            PlayerHandlers.KickBall(p, (float)(seconddir.X * 0.3), 0, (float)(seconddir.Z * 0.3));
        }
Esempio n. 9
0
        public override void ExecuteLeft(Player p)
        {
            var dir = DirUtils.GetDirVector(p.rot[0], p.rot[1]);

            PlayerHandlers.KickBall(p, (float)(dir.X * -0.2), 0, (float)(dir.Z * -0.2));
            byte yaw        = (byte)((p.rot[0] + 128) % 256);
            byte targetkick = (byte)((p.rot[0] - 64) % 256);
            var  targetdir  = DirUtils.GetDirVector(targetkick, p.rot[1]);

            p.SendPos(p.id, p.pos[0], p.pos[1], p.pos[2], yaw, p.rot[1]);
            Thread.Sleep(1000);
            PlayerHandlers.KickBall(p, (float)(targetdir.X * 0.4), 0, (float)(targetdir.Z * 0.4));
            p.SendPos(p.id, p.pos[0], p.pos[1], p.pos[2], targetkick, p.rot[1]);
        }
Esempio n. 10
0
        public override void ExecuteLeft(Player p)
        {
            byte    length    = 32;
            Vec3F32 dirVector = DirUtils.GetDirVector((byte)((p.rot[0] - 32) % 256), p.rot[1]);

            ushort newX = (ushort)(p.pos[0] + dirVector.X * length);
            ushort newZ = (ushort)(p.pos[2] + dirVector.Z * length);

            foreach (Player pl in Player.players)
            {
                if (pl != p && pl.level == p.level)
                {
                    pl.SendPos(p.id, newX, p.pos[1], newZ, p.rot[0], p.rot[1]);
                }
            }
        }
Esempio n. 11
0
        static void DoAim(AimState state)
        {
            Player  p   = state.player;
            Vec3F32 dir = DirUtils.GetDirVector(p.Rot.RotY, p.Rot.HeadX);
            ushort  x   = (ushort)Math.Round(p.Pos.BlockX + dir.X * 3);
            ushort  y   = (ushort)Math.Round(p.Pos.BlockY + dir.Y * 3);
            ushort  z   = (ushort)Math.Round(p.Pos.BlockZ + dir.Z * 3);

            int signX = Math.Sign(dir.X) >= 0 ? 1 : -1, signZ = Math.Sign(dir.Z) >= 0 ? 1 : -1;

            CheckTile(p.level, state.glassCoords, x, y, z);
            CheckTile(p.level, state.glassCoords, x + signX, y, z);
            CheckTile(p.level, state.glassCoords, x, y, z + signZ);
            CheckTile(p.level, state.glassCoords, x + signX, y, z + signZ);

            // Revert all glass blocks now not in the ray from the player's direction
            for (int i = 0; i < state.lastGlass.Count; i++)
            {
                Vec3U16 pos = state.lastGlass[i];
                if (state.glassCoords.Contains(pos))
                {
                    continue;
                }

                if (p.level.IsValidPos(pos))
                {
                    p.RevertBlock(pos.X, pos.Y, pos.Z);
                }
                state.lastGlass.RemoveAt(i); i--;
            }

            // Place the new glass blocks that are in the ray from the player's direction
            foreach (Vec3U16 pos in state.glassCoords)
            {
                if (state.lastGlass.Contains(pos))
                {
                    continue;
                }
                state.lastGlass.Add(pos);
                p.SendBlockchange(pos.X, pos.Y, pos.Z, Block.Glass);
            }
            state.glassCoords.Clear();
        }
Esempio n. 12
0
        void Update()
        {
            Player  p   = player;
            Vec3F32 dir = DirUtils.GetDirVector(p.Rot.RotY, p.Rot.HeadX);
            ushort  x   = (ushort)Math.Round(p.Pos.BlockX + dir.X * 3);
            ushort  y   = (ushort)Math.Round(p.Pos.BlockY + dir.Y * 3);
            ushort  z   = (ushort)Math.Round(p.Pos.BlockZ + dir.Z * 3);

            int dx = Math.Sign(dir.X) >= 0 ? 1 : -1, dz = Math.Sign(dir.Z) >= 0 ? 1 : -1;

            Check(p.level, x, y, z);
            Check(p.level, x + dx, y, z);
            Check(p.level, x, y, z + dz);
            Check(p.level, x + dx, y, z + dz);

            // Revert all glass blocks now not in the ray from the player's direction
            for (int i = 0; i < lastGlass.Count; i++)
            {
                Vec3U16 pos = lastGlass[i];
                if (curGlass.Contains(pos))
                {
                    continue;
                }

                if (p.level.IsValidPos(pos))
                {
                    p.RevertBlock(pos.X, pos.Y, pos.Z);
                }
                lastGlass.RemoveAt(i); i--;
            }

            // Place the new glass blocks that are in the ray from the player's direction
            foreach (Vec3U16 pos in curGlass)
            {
                if (lastGlass.Contains(pos))
                {
                    continue;
                }
                lastGlass.Add(pos);
                p.SendBlockchange(pos.X, pos.Y, pos.Z, Block.Glass);
            }
            curGlass.Clear();
        }
Esempio n. 13
0
 public static void Execute(Player p, int skill)
 {
     try
     {
         string line;
         var    Dir    = DirUtils.GetDirVector(p.rot[0], p.rot[1]);
         var    MaxDir = DirUtils.GetDirVector(255, 255);
         // Read the file and display it line by line.
         System.IO.StreamReader file =
             new System.IO.StreamReader("skills/" + p.name.ToLower() + skill.ToString() + ".txt");
         while ((line = file.ReadLine()) != null)
         {
             if (line.StartsWith("Kick("))
             {
                 //Kick(X, Y, Z);
                 var line_ = line.Replace("Kick(", "").Replace(");", "").Replace(" ", "").Replace("X", Dir.X.ToString())
                             .Replace("Y", Dir.Y.ToString()).Replace("Z", Dir.Z.ToString()).Split(',');
                 var X = Evaluate(line_[0]);
                 var Y = Evaluate(line_[1]);
                 var Z = Evaluate(line_[2]);
                 PlayerHandlers.KickBall(p, X, Y, Z);
                 Thread.Sleep(500);
             }
             //Kick X Y Z
             if (line.StartsWith("Kick "))
             {
                 //Kick(X, Y, Z);
                 var line_ = line.Replace("Kick ", "").Replace(");", "").Replace(" ", "").Replace("X", Dir.X.ToString())
                             .Replace("Y", Dir.Y.ToString()).Replace("Z", Dir.Z.ToString()).Split(',');
                 var X = Evaluate(line_[0]);
                 var Y = Evaluate(line_[1]);
                 var Z = Evaluate(line_[2]);
                 PlayerHandlers.KickBall(p, X, Y, Z);
                 Thread.Sleep(500);
             }
         }
     }
     catch
     {
         p.SendMessage("Error in Skill #" + skill.ToString());
     }
 }
Esempio n. 14
0
        public override void ExecuteLeft(Player p)
        {
            var dir = DirUtils.GetDirVector(p.rot[0], p.rot[1]);

            PlayerHandlers.KickBall(p, (float)(dir.X * -0.4), 0.4f, (float)(dir.Z * -0.4));
        }
Esempio n. 15
0
        public override void ExecuteRight(Player p)
        {
            var dir = DirUtils.GetDirVector(p.rot[0], p.rot[1]);

            PlayerHandlers.KickBall(p, (float)(dir.X * 0.1), 0.3f, (float)(dir.Z * 0.1));
        }