Example #1
0
        void HandleRelPositionUpdate()
        {
            byte  id = reader.ReadUInt8();
            float x  = reader.ReadInt8() / 32f;
            float y  = reader.ReadInt8() / 32f;
            float z  = reader.ReadInt8() / 32f;

            LocationUpdate update = LocationUpdate.MakePos(x, y, z, true);

            net.UpdateLocation(id, update, true);
        }
Example #2
0
        void HandleRelPositionUpdate()
        {
            byte    id = reader.ReadUInt8();
            Vector3 v;

            v.X = reader.ReadInt8() / 32f;
            v.Y = reader.ReadInt8() / 32f;
            v.Z = reader.ReadInt8() / 32f;

            LocationUpdate update = LocationUpdate.MakePos(v, true);

            net.UpdateLocation(id, update, true);
        }
Example #3
0
        public void OnNewMapLoaded(Game game)
        {
            UpdateScore();
            string[] models = { "sheep", "pig", "skeleton", "zombie", "creeper", "spider" };
            for (int i = 0; i < 254; i++)
            {
                MobEntity fail = new MobEntity(game, models[rnd.Next(models.Length)]);
                float     x    = rnd.Next(0, game.World.Width) + 0.5f;
                float     z    = rnd.Next(0, game.World.Length) + 0.5f;

                Vector3 pos = Respawn.FindSpawnPosition(game, x, z, fail.Size);
                fail.SetLocation(LocationUpdate.MakePos(pos, false), false);
                game.Entities[i] = fail;
            }
        }
Example #4
0
        void Scheduled(ScheduledTask task)
        {
            if (!MountingEnabled)
            {
                return;
            }
            float curScale = Ggame.LocalPlayer.ModelScale.Y;

            if (mountingId != -1 && mountingId != 255)
            {
                if (Ggame.Entities.List[mountingId] == null)
                {
                    Ggame.Server.SendChat("/model " + Ggame.Username + " humanoid");  Ggame.LocalPlayer.Hacks.Floating = false; mountingId = -1; return;
                }
                Ggame.LocalPlayer.Hacks.Floating = true;
                Ggame.LocalPlayer.Velocity.Y     = 0;
                float offSetY = 1;
                if (Ggame.LocalPlayer.ModelScale.Y <= 0.5)
                {
                    switch (Ggame.Entities.List[mountingId].ModelName)
                    {
                    case "sit": offSetY = 1; break;

                    case "pony": offSetY = 1.5f; break;

                    case "ponysit": offSetY = 1.4f; break;

                    default: offSetY = 2; break;
                    }
                }
                else
                {
                    switch (Ggame.Entities.List[mountingId].ModelName)
                    {
                    case "sit":
                    case "spider":
                    case "ponysit":
                    case "pony": offSetY = 1; break;

                    default: offSetY = 1.5f; break;
                    }
                }

                Vector3        v      = new Vector3(Ggame.Entities.List[mountingId].Position.X, Ggame.Entities.List[mountingId].Position.Y + offSetY, Ggame.Entities.List[mountingId].Position.Z);
                LocationUpdate update = LocationUpdate.MakePos(v, false);
                Ggame.LocalPlayer.SetLocation(update, false);
            }
        }
        void verifyplayerhp()
        {
            if (game.LocalPlayer.Health < 1)
            {
                Vector3 Newpos;
                Newpos.X = (float)game.World.Width / 2;
                Newpos.Z = (float)game.World.Length / 2;

                Newpos = Respawn.FindSpawnPosition(game, Newpos.Z, Newpos.X, game.LocalPlayer.Size);

                LocationUpdate update = LocationUpdate.MakePos(Newpos, false);
                game.LocalPlayer.SetLocation(update, false);
                game.LocalPlayer.Health = 20;
                game.Chat.Add("You died.");
            }
        }
Example #6
0
        } //Verify Player HP

        void Respawning()
        {
            game.LocalPlayer.Velocity.X = 0;
            game.LocalPlayer.Velocity.Y = 0;
            game.LocalPlayer.Velocity.Z = 0;

            Vector3 Newpos;

            Newpos.X = (float)game.World.Width / 2;
            Newpos.Z = (float)game.World.Length / 2;

            Newpos = Respawn.FindSpawnPosition(game, (int)Newpos.Z, (int)Newpos.X, game.LocalPlayer.Size);


            LocationUpdate update = LocationUpdate.MakePos(Newpos, false);

            game.LocalPlayer.SetLocation(update, true);
        }
Example #7
0
        void IGameComponent.OnNewMapLoaded(Game game)
        {
            UpdateScore();
            wasOnGround             = true;
            showedDeathScreen       = false;
            game.LocalPlayer.Health = 20;
            string[] models = { "sheep", "pig", "skeleton", "zombie", "creeper", "spider" };

            for (int i = 0; i < 254; i++)
            {
                MobEntity fail = new MobEntity(game, models[rnd.Next(models.Length)]);
                float     x    = rnd.Next(0, game.World.Width) + 0.5f;
                float     z    = rnd.Next(0, game.World.Length) + 0.5f;

                Vector3 pos = Respawn.FindSpawnPosition(game, x, z, fail.Size);
                fail.SetLocation(LocationUpdate.MakePos(pos, false), false);
                game.Entities.List[i] = fail;
            }
        }
Example #8
0
        public override void Execute(string[] args)
        {
            if (args.Length != 4)
            {
                game.Chat.Add("&e/client teleport: &cYou didn't specify X, Y and Z coordinates.");
            }
            else
            {
                float x = 0, y = 0, z = 0;
                if (!Utils.TryParseDecimal(args[1], out x) ||
                    !Utils.TryParseDecimal(args[2], out y) ||
                    !Utils.TryParseDecimal(args[3], out z))
                {
                    game.Chat.Add("&e/client teleport: &cCoordinates must be decimals");
                }

                LocationUpdate update = LocationUpdate.MakePos(x, y, z, false);
                game.LocalPlayer.SetLocation(update, false);
            }
        }
Example #9
0
        void SpawnItem(BlockID item, byte count, Vector3 pos)
        {
            if (!game.Server.IsSinglePlayer)
            {
                game.SurvInv.TryAddItem((sbyte)count, item);
                return;
            }
            int id = game.Entities.NextFreeID();

            if (id == -1)
            {
                AddToHotbar(item, count);
                return;
            }
            EntityItem newEnt = new EntityItem(game);

            newEnt.ItemId    = item;
            newEnt.ItemCount = (sbyte)count;
            newEnt.SetLocation(LocationUpdate.MakePos(pos, false), false);
            game.Entities.List[id] = newEnt;
        }
Example #10
0
        void HandleTnt(int index, BlockID block)
        {
            float x = (index % map.Width) + 0.5f;
            float z = ((index / map.Width) % map.Length) + 0.5f;
            float y = ((index / map.Width) / map.Length);

            TntEntity TNT = new TntEntity(game, -1, 4);
            Vector3   pos = new Vector3(x, y, z);

            TNT.SetLocation(LocationUpdate.MakePos(pos, false), false);
            var ent    = game.Entities;
            var entLen = game.Entities.Entities.Length;

            for (int i = entLen - 1; i >= 0; i--)
            {
                if (ent[i] == null)
                {
                    ent[i] = TNT;
                    break;
                }
            }
        }
        public void OnNewMapLoaded(Game game)
        {
            for (int i = 0; i < ((int)((oldlength + oldwidth / 2) / 5)); i++)
            {
                game.Entities[i] = null;
            }

            game.Chat.Add("&fScore: &e" + score, MessageType.Status1);
            string[] models = { "sheep", "pig", "skeleton", "zombie", "creeper", "spider" };
            for (int i = 0; i < ((int)((game.World.Length + game.World.Width / 2) / 5)); i++)
            {
                MobEntity fail = new MobEntity(game, models[rnd.Next(models.Length)]);
                float     x    = rnd.Next(0, game.World.Width) + 0.5f;
                float     z    = rnd.Next(0, game.World.Length) + 0.5f;

                Vector3 pos = Respawn.FindSpawnPosition(game, x, z, fail.Size);
                fail.SetLocation(LocationUpdate.MakePos(pos, false), false);
                game.Entities[i]        = fail;
                game.Entities[i].Health = 10;
            }
            oldwidth  = game.World.Width;
            oldlength = game.World.Length;
        }
        public override void Execute(string[] args)
        {
            if (args.Length != 2 && args.Length != 3)
            {
                game.Chat.Add("Unspecified error");
            }
            else
            {
                BlockID    id   = 5;
                EntityItem Item = new EntityItem(game);
                if (!BlockID.TryParse(args[1], out id))
                {
                    game.Chat.Add("Unspecified error");
                    return;
                }

                Item.ItemId = id;
                float   x   = game.LocalPlayer.Position.X;
                float   z   = game.LocalPlayer.Position.Z;
                Vector3 pos = Respawn.FindSpawnPosition(game, x, z, Item.Size);
                Item.SetLocation(LocationUpdate.MakePos(pos, false), false);
                game.Entities.List[200] = Item;
            }
        }