Exemplo n.º 1
0
        /// <summary>
        /// Gets a chest's internal type code.
        /// </summary>
        /// <param name="tileType"></param>
        /// <returns></returns>
        public static int?GetChestTypeCode(int tileType)
        {
            switch (tileType)
            {
            case TileID.Containers:
                return(0);

            case TileID.Containers2:
                return(4);

            case TileID.Dressers:
                return(2);

            default:
                if (TileID.Sets.BasicChest[tileType])
                {
                    return(100);
                }
                else if (TileLoader.IsDresser(tileType))
                {
                    return(102);
                }
                break;
            }
            return(null);           //1?
        }
Exemplo n.º 2
0
        private int FindChest(int x, int y)
        {
            Tile tile = Main.tile[x, y];

            if (tile == null || !tile.active())
            {
                return(-1);
            }

            int originX = x;
            int originY = y;

            if (TileLoader.IsDresser(tile.type))
            {
                originX -= tile.frameX % 54 / 18;
            }
            else
            {
                originX -= tile.frameX % 36 / 18;
            }

            originY -= tile.frameY % 36 / 18;

            if (!Chest.isLocked(originX, originY))
            {
                return(Chest.FindChest(originX, originY));
            }
            else
            {
                return(-1);
            }
        }
 public override bool CanPlace(int i, int j, int type)
 {
     if (TileID.Sets.BasicChest[type] || TileID.Sets.BasicChestFake[type] || TileLoader.IsDresser(type))
     {
         Tile bottom = Main.tile[i, j + 1];
         if (bottom != null && bottom.active() && bottom.type == mod.TileType <WirelessTeleporterTile>())
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 4
0
 public override bool CanPlace(int i, int j, int type)
 {
     if (TileID.Sets.BasicChest[type] || TileID.Sets.BasicChestFake[type] || TileLoader.IsDresser(type))
     {
         Tile bottom = Main.tile[i, j + 1];
         if (bottom != null && bottom.active() && noChestTiles.Contains(bottom.type))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 5
0
        //This needs to be called from SetupRecipies, because chests are made in SetupContent.
        private void LoadChestAdapters()
        {
            ChestAdapter chestAdapter = new ChestAdapter(this);
            List <int>   chestTypes   = new List <int>();

            for (int i = 0; i < TileLoader.TileCount; i++)
            {
                if (TileID.Sets.BasicChest[i] || TileID.Sets.BasicChestFake[i] || TileLoader.IsDresser(i))
                {
                    chestTypes.Add(i);
                }
            }
            Call(registerAdapterReflection, chestAdapter, chestTypes.ToArray());
        }
Exemplo n.º 6
0
        /// <summary>
        /// <para>Hit tile with pick without needing a player.</para>
        /// <para>Equivalent to if an actual player hit it.</para>
        /// <para>Modified from Terraria's Player.PickTile code.</para>
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="pickPower"></param>
        public static void PickTile(int x, int y, int pickPower)
        {
            int  damage = 0;
            int  tileId = MoreMechanisms.globalHitTile.HitObject(x, y, 1);
            Tile tile   = Main.tile[x, y];

            if (Main.tileNoFail[tile.type])
            {
                damage = 100;
            }

            if (Main.tileDungeon[tile.type] || tile.type == 25 || tile.type == 58 || tile.type == 117 || tile.type == 203)
            {
                damage += pickPower / 2;
            }
            else if (tile.type == 48 || tile.type == 232)
            {
                damage += pickPower / 4;
            }
            else if (tile.type == 226)
            {
                damage += pickPower / 4;
            }
            else if (tile.type == 107 || tile.type == 221)
            {
                damage += pickPower / 2;
            }
            else if (tile.type == 108 || tile.type == 222)
            {
                damage += pickPower / 3;
            }
            else if (tile.type == 111 || tile.type == 223)
            {
                damage += pickPower / 4;
            }
            else if (tile.type == 211)
            {
                damage += pickPower / 5;
            }
            else
            {
                TileLoader.MineDamage(pickPower, ref damage);
            }

            if (tile.type == 211 && pickPower < 200)
            {
                damage = 0;
            }

            if ((tile.type == 25 || tile.type == 203) && pickPower < 65)
            {
                damage = 0;
            }
            else if (tile.type == 117 && pickPower < 65)
            {
                damage = 0;
            }
            else if (tile.type == 37 && pickPower < 50)
            {
                damage = 0;
            }
            else if (tile.type == 404 && pickPower < 65)
            {
                damage = 0;
            }
            else
            {
                if ((tile.type == 22 || tile.type == 204) && (double)y > Main.worldSurface && pickPower < 55)
                {
                    damage = 0;
                }
                else if (tile.type == 56 && pickPower < 65)
                {
                    damage = 0;
                }
                else if (tile.type == 58 && pickPower < 65)
                {
                    damage = 0;
                }
                else
                {
                    if ((tile.type == 226 || tile.type == 237) && pickPower < 210)
                    {
                        damage = 0;
                    }
                    else if (Main.tileDungeon[tile.type] && pickPower < 65)
                    {
                        if ((double)x < (double)Main.maxTilesX * 0.35 || (double)x > (double)Main.maxTilesX * 0.65)
                        {
                            damage = 0;
                        }
                    }
                    else if (tile.type == 107 && pickPower < 100)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 108 && pickPower < 110)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 111 && pickPower < 150)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 221 && pickPower < 100)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 222 && pickPower < 110)
                    {
                        damage = 0;
                    }
                    else if (tile.type == 223 && pickPower < 150)
                    {
                        damage = 0;
                    }
                    else
                    {
                        TileLoader.PickPowerCheck(tile, pickPower, ref damage);
                    }
                }
            }

            if (tile.type == 147 || tile.type == 0 || tile.type == 40 || tile.type == 53 || tile.type == 57 || tile.type == 59 || tile.type == 123 || tile.type == 224 || tile.type == 397)
            {
                damage += pickPower;
            }

            if (tile.type == 165 || Main.tileRope[tile.type] || tile.type == 199 || Main.tileMoss[tile.type])
            {
                damage = 100;
            }

            if (MoreMechanisms.globalHitTile.AddDamage(tileId, damage, false) >= 100 && (tile.type == 2 || tile.type == 23 || tile.type == 60 || tile.type == 70 || tile.type == 109 || tile.type == 199 || Main.tileMoss[tile.type]))
            {
                damage = 0;
            }

            if (tile.type == 128 || tile.type == 269)
            {
                if (tile.frameX == 18 || tile.frameX == 54)
                {
                    x--;
                    tile = Main.tile[x, y];
                    MoreMechanisms.globalHitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameX >= 100)
                {
                    damage          = 0;
                    Main.blockMouse = true;
                }
            }

            if (tile.type == 334)
            {
                if (tile.frameY == 0)
                {
                    y++;
                    tile = Main.tile[x, y];
                    MoreMechanisms.globalHitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameY == 36)
                {
                    y--;
                    tile = Main.tile[x, y];
                    MoreMechanisms.globalHitTile.UpdatePosition(tileId, x, y);
                }
                int  j      = tile.frameX;
                bool flag   = j >= 5000;
                bool cancel = false;
                if (!flag)
                {
                    int num5 = j / 18;
                    num5 %= 3;
                    x    -= num5;
                    tile  = Main.tile[x, y];
                    if (tile.frameX >= 5000)
                    {
                        flag = true;
                    }
                }

                if (flag)
                {
                    j = tile.frameX;
                    int num3 = 0;
                    while (j >= 5000)
                    {
                        j -= 5000;
                        num3++;
                    }
                    if (num3 != 0)
                    {
                        cancel = true;
                    }
                }

                if (cancel)
                {
                    damage          = 0;
                    Main.blockMouse = true;
                }
            }

            if (!WorldGen.CanKillTile(x, y))
            {
                damage = 0;
            }

            if (MoreMechanisms.globalHitTile.AddDamage(tileId, damage, true) >= 100)
            {
                //AchievementsHelper.CurrentlyMining = true;
                MoreMechanisms.globalHitTile.Clear(tileId);
                if (Main.netMode == 1 && Main.tileContainer[Main.tile[x, y].type])
                {
                    WorldGen.KillTile(x, y, true, false, false);
                    NetMessage.SendData(17, -1, -1, null, 0, (float)x, (float)y, 1f, 0, 0, 0);
                    if (Main.tile[x, y].type == 21 || (Main.tile[x, y].type >= 470 && TileID.Sets.BasicChest[Main.tile[x, y].type]))
                    {
                        NetMessage.SendData(34, -1, -1, null, 1, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                    if (Main.tile[x, y].type == 467)
                    {
                        NetMessage.SendData(34, -1, -1, null, 5, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                    if (TileLoader.IsDresser(Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, null, 3, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                    if (Main.tile[x, y].type >= 470 && TileID.Sets.BasicChest[Main.tile[x, y].type])
                    {
                        NetMessage.SendData(34, -1, -1, null, 101, (float)x, (float)y, 0f, 0, Main.tile[x, y].type, 0);
                    }
                    if (Main.tile[x, y].type >= 470 && TileLoader.IsDresser(Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, null, 103, (float)x, (float)y, 0f, 0, Main.tile[x, y].type, 0);
                    }
                }
                else
                {
                    int  num2 = y;
                    bool num6 = Main.tile[x, num2].active();
                    WorldGen.KillTile(x, num2, false, false, false);
                    if (num6 && !Main.tile[x, num2].active())
                    {
                        //AchievementsHelper.HandleMining();
                    }
                    if (Main.netMode == 1)
                    {
                        NetMessage.SendData(17, -1, -1, null, 0, (float)x, (float)num2, 0f, 0, 0, 0);
                    }
                }
                //AchievementsHelper.CurrentlyMining = false;
            }
            else
            {
                WorldGen.KillTile(x, y, true, false, false);
                if (Main.netMode == 1)
                {
                    NetMessage.SendData(17, -1, -1, null, 0, (float)x, (float)y, 1f, 0, 0, 0);
                }
            }
            if (damage != 0)
            {
                MoreMechanisms.globalHitTile.Prune();
            }
        }
        public override void Explosion()    // This is a special explosive, ignored
        {
            //if (Main.player[projectile.owner].EE().BombardEmblem) return;
            Vector2 position = projectile.position;
            int     width    = 240; //Width of arena
            int     height   = 120; //Height of arena

            int x = 0;
            int y = 0;

            int platformCntr = height - 15; //Space between platform layers

            for (x = -(width / 2); x <= width / 2; x++)
            {
                for (y = height - 1; y >= 0; y--)
                {
                    int xPosition = (int)(x + position.X / 16.0f);
                    int yPosition = (int)(-y + position.Y / 16.0f);

                    if (!WorldGen.InWorld(xPosition, yPosition))
                    {
                        continue;
                    }

                    Tile tile = Framing.GetTileSafely(xPosition, yPosition);

                    if (WorldGen.InWorld(xPosition, yPosition) && tile.active())
                    {
                        if (!CanBreakTile(tile.type, PickPower)) //Unbreakable CheckForUnbreakableTiles(tile) ||
                        {
                        }
                        else //Breakable
                        {
                            if (!TileID.Sets.BasicChest[Main.tile[xPosition, yPosition - 1].type] && !TileLoader.IsDresser(Main.tile[xPosition, yPosition - 1].type) && Main.tile[xPosition, yPosition - 1].type != 26)
                            {
                                tile.ClearTile();
                                tile.active(false);
                            }

                            if (Main.netMode == NetmodeID.MultiplayerClient)
                            {
                                WorldGen.SquareTileFrame(xPosition, yPosition, true); //Updates Area
                                NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)xPosition, (float)yPosition, 0f, 0, 0, 0);
                            }

                            if (CanBreakWalls)
                            {
                                WorldGen.KillWall(xPosition, yPosition, false);                //This destroys Walls
                            }
                        }
                    }

                    //The following happens whether the block is breakable or not as the following methods cannot break or replace blocks that already exist.
                    if (!OutOfBounds(xPosition, yPosition))
                    {
                        //Breaks Liquid
                        Main.tile[xPosition, yPosition].liquid = Tile.Liquid_Water;
                        WorldGen.SquareTileFrame(xPosition, yPosition, true);

                        //Place Arena Outline
                        if (y == 0 || y == height - 1)
                        {
                            WorldGen.PlaceTile(xPosition, yPosition, TileID.CrystalBlock);
                        }
                        if ((x == -(width / 2) || x == (width / 2)) && (y != 0 || y != height - 1))
                        {
                            WorldGen.PlaceTile(xPosition, yPosition, TileID.CrystalBlock);
                        }

                        //Places Arena Platforms
                        if (y == platformCntr && (x != -(width / 2) || x != (width / 2)))
                        {
                            WorldGen.PlaceTile(xPosition, yPosition, TileID.Platforms);
                            platformCntr -= 15;
                        }
                    }
                }
                platformCntr = height - 15; //Decrease the platformCntr
            }
            platformCntr = 15;              //Reset the platformCntr

            //Now that the space has been cleared and an outline has been established, the arena can be filled.
            for (x = -(width / 2); x < width / 2; x++)
            {
                for (y = 0; y < height; y++)
                {
                    int xPosition = (int)(x + position.X / 16.0f);
                    int yPosition = (int)(-y + position.Y / 16.0f);

                    if (!OutOfBounds(xPosition, yPosition))
                    {
                        //Campfires
                        if (y == platformCntr && (x != -(width / 2) || x != (width / 2)))
                        {
                            if (x == -64 || x == 0 || x == 64)
                            {
                                WorldGen.PlaceTile(xPosition, yPosition - 1, TileID.Campfire);
                            }

                            platformCntr += 30;
                        }
                    }
                }
                platformCntr = 15; //Reset the platformCntr
            }
            platformCntr = 15;     //Reset the platformCntr

            //More arena filling
            for (x = -(width / 2); x < width / 2; x++)
            {
                for (y = 0; y < height; y++)
                {
                    int xPosition = (int)(x + position.X / 16.0f);
                    int yPosition = (int)(-y + position.Y / 16.0f);

                    if (!OutOfBounds(xPosition, yPosition))
                    {
                        //Torches
                        if (y == platformCntr && (x != -(width / 2) || x != (width / 2)))
                        {
                            if (x == -112 || x == -100 || x == -88 || x == -76 || x == -52 || x == -40 || x == -28 || x == -16 || x == -4 || x == 4 || x == 16 || x == 28 || x == 40 || x == 52 || x == 76 || x == 88 || x == 100 || x == 112)
                            {
                                WorldGen.PlaceTile(xPosition, yPosition - 1, TileID.Torches);
                            }

                            platformCntr += 15;
                        }
                    }
                }
                platformCntr = 15;
            }

            //More arena filling
            for (x = -(width / 2); x < width / 2; x++)
            {
                for (y = 0; y < height; y++)
                {
                    int xPosition = (int)(x + position.X / 16.0f);
                    int yPosition = (int)(-y + position.Y / 16.0f);

                    if (!OutOfBounds(xPosition, yPosition))
                    {
                        //Spawn & Nurse
                        if (x > 99)    //X confines
                        {
                            if (y < 7) //Y confines
                            {
                                //Walls
                                if (x == 100 && (y == 4 || y == 5))
                                {
                                    WorldGen.PlaceTile(xPosition, yPosition, TileID.CrystalBlock);
                                }
                                if (x == 109 && (y == 4 || y == 5))
                                {
                                    WorldGen.PlaceTile(xPosition, yPosition, TileID.CrystalBlock);
                                }

                                //Roof
                                if (y == 6 && (x != 100 || x != 120))
                                {
                                    WorldGen.PlaceTile(xPosition, yPosition, TileID.CrystalBlock);
                                }

                                //Background
                                if (x > 100 && x < 120)
                                {
                                    //Break Walls
                                    WorldGen.KillWall(xPosition, yPosition);

                                    //Places Walls
                                    if (y == 5 || y == 2 || y == 1)
                                    {
                                        WorldGen.PlaceWall(xPosition, yPosition, WallID.Wood);
                                    }
                                    if (y == 3 || y == 4)
                                    {
                                        if (x == 113 || x == 114 || x == 115)
                                        {
                                            WorldGen.PlaceWall(xPosition, yPosition, WallID.Glass);
                                        }
                                        else
                                        {
                                            WorldGen.PlaceWall(xPosition, yPosition, WallID.Wood);
                                        }
                                    }
                                }

                                //Lights
                                if (y == 5)
                                {
                                    if (x == 101 || x == 108 || x == 110 || x == 119)
                                    {
                                        WorldGen.PlaceTile(xPosition, yPosition, TileID.Torches);
                                    }
                                }

                                //Furniture
                                if (y == 1)
                                {
                                    if (x == 105)
                                    {
                                        WorldGen.PlaceTile(xPosition, yPosition, TileID.Beds);
                                    }
                                    else if (x == 114)
                                    {
                                        WorldGen.PlaceTile(xPosition, yPosition, TileID.Tables);
                                    }
                                    else if (x == 116)
                                    {
                                        WorldGen.PlaceTile(xPosition, yPosition, TileID.Chairs);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //More arena filling
            for (x = -(width / 2); x < width / 2; x++)
            {
                for (y = 0; y < height; y++)
                {
                    int xPosition = (int)(x + position.X / 16.0f);
                    int yPosition = (int)(-y + position.Y / 16.0f);

                    if (!OutOfBounds(xPosition, yPosition))
                    {
                        //Spawn & Nurse additional
                        if (x > 99)    //X confines
                        {
                            if (y < 7) //Y confines
                            {
                                //Doors
                                if (y == 1)
                                {
                                    if (x == 100)
                                    {
                                        WorldGen.PlaceTile(xPosition, yPosition, TileID.ClosedDoor);
                                    }
                                    else if (x == 109)
                                    {
                                        WorldGen.PlaceTile(xPosition, yPosition, TileID.ClosedDoor);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        // This is basically a hack, needed because mining the bottom of a trap while a chest is placed on top can break the game
        public static bool CanMineTrap(int i, int j, ushort trap)
        {
            int y = j - (Main.tile[i, j].frameY / 18);
            int x = i - ((Main.tile[i, j].frameX % 36) / 18);

            ushort type1 = Main.tile[x, y - 1].type, type2 = Main.tile[x + 1, y - 1].type;
            bool   cankill = !TileID.Sets.BasicChest[type2] && !TileID.Sets.BasicChest[type1] && !TileID.Sets.BasicChestFake[type1] && !TileID.Sets.BasicChestFake[type2] && !TileLoader.IsDresser(type2) && !TileLoader.IsDresser(type1);

            if (cankill)
            {
                if (y != j || x == i)
                {
                    Main.tile[x + 1, y].type = TileID.Stone;
                    cankill &= WorldGen.CanKillTile(x + 1, y);
                    Main.tile[x + 1, y].type = trap;
                }
                if (y != j || x != i)
                {
                    Main.tile[x, y].type = TileID.Stone;
                    cankill &= WorldGen.CanKillTile(x, y);
                    Main.tile[x, y].type = trap;
                }
            }
            return(cankill);
        }
        public override void Explosion()
        {
            Vector2 position = projectile.Center;
            int     width    = 3;                   //Explosion Width for both sides starting from the center
            int     height   = Main.maxTilesY - 10; //Explosion Height

            if (Main.netMode == NetmodeID.MultiplayerClient)
            {
                return;
            }

            for (int x = -width; x < width; x++)
            {
                for (int y = 0; y <= height; y++)
                {
                    int i = (int)(x + position.X / 16.0f);
                    int j = (int)(y + position.Y / 16.0f);

                    if (WorldGen.InWorld(i, j))
                    {
                        Tile   tile  = Framing.GetTileSafely(i, j);
                        ushort tileP = tile.type;

                        if (!CanBreakTile(tileP, pickPower)) //Unbreakable CheckForUnbreakableTiles(tile) ||
                        {
                        }
                        else //Breakable
                        {
                            if (!TileID.Sets.BasicChest[Main.tile[i, j - 1].type] && !TileLoader.IsDresser(Main.tile[i, j - 1].type) && Main.tile[i, j - 1].type != 26)
                            {
                                tile.ClearTile();
                                tile.active(false);
                            }
                            if (CanBreakWalls)
                            {
                                WorldGen.KillWall(i, j, false);                //This destroys Walls
                            }
                            if (CanBreakWalls && y - 1 != height)
                            {
                                WorldGen.KillWall(i + 1, j + 1, false);                                   //Break the last bit of wall
                            }
                            NetMessage.SendTileSquare(-1, i, j, 1);
                        }

                        Main.tile[i, j].liquid = Tile.Liquid_Water; //This destroys liquids
                        WorldGen.SquareTileFrame(i, j, true);       //Updates Area
                    }
                }
            }
        }
Exemplo n.º 10
0
        public void PickTile2(int x, int y, int pickPower, Tiles.AutoPicker autoPicker)
        {
            int  num8   = 0;
            int  tileId = hitTile.HitObject(x, y, 1);
            Tile tile   = Main.tile[x, y];

            if (Main.tileNoFail[tile.type])
            {
                num8 = 100;
            }
            if (Main.tileDungeon[tile.type] || tile.type == 25 || tile.type == 58 || tile.type == 117 || tile.type == 203)
            {
                num8 += pickPower / 2;
            }
            else if (tile.type == 48 || tile.type == 232)
            {
                num8 += pickPower / 4;
            }
            else if (tile.type == 226)
            {
                num8 += pickPower / 4;
            }
            else if (tile.type == 107 || tile.type == 221)
            {
                num8 += pickPower / 2;
            }
            else if (tile.type == 108 || tile.type == 222)
            {
                num8 += pickPower / 3;
            }
            else if (tile.type == 111 || tile.type == 223)
            {
                num8 += pickPower / 4;
            }
            else if (tile.type == 211)
            {
                num8 += pickPower / 5;
            }
            else
            {
                TileLoader.MineDamage(pickPower, ref num8);
            }
            if (tile.type == 211 && pickPower < 200)
            {
                num8 = 0;
            }
            if ((tile.type == 25 || tile.type == 203) && pickPower < 65)
            {
                num8 = 0;
            }
            else if (tile.type == 117 && pickPower < 65)
            {
                num8 = 0;
            }
            else if (tile.type == 37 && pickPower < 50)
            {
                num8 = 0;
            }
            else if (tile.type == 404 && pickPower < 65)
            {
                num8 = 0;
            }
            else if ((tile.type == 22 || tile.type == 204) && (double)y > Main.worldSurface && pickPower < 55)
            {
                num8 = 0;
            }
            else if (tile.type == 56 && pickPower < 65)
            {
                num8 = 0;
            }
            else if (tile.type == 58 && pickPower < 65)
            {
                num8 = 0;
            }
            else if ((tile.type == 226 || tile.type == 237) && pickPower < 210)
            {
                num8 = 0;
            }
            else if (Main.tileDungeon[tile.type] && pickPower < 65)
            {
                if ((double)x < (double)Main.maxTilesX * 0.35 || (double)x > (double)Main.maxTilesX * 0.65)
                {
                    num8 = 0;
                }
            }
            else if (tile.type == 107 && pickPower < 100)
            {
                num8 = 0;
            }
            else if (tile.type == 108 && pickPower < 110)
            {
                num8 = 0;
            }
            else if (tile.type == 111 && pickPower < 150)
            {
                num8 = 0;
            }
            else if (tile.type == 221 && pickPower < 100)
            {
                num8 = 0;
            }
            else if (tile.type == 222 && pickPower < 110)
            {
                num8 = 0;
            }
            else if (tile.type == 223 && pickPower < 150)
            {
                num8 = 0;
            }
            else
            {
                TileLoader.PickPowerCheck(tile, pickPower, ref num8);
            }
            if (tile.type == 147 || tile.type == 0 || tile.type == 40 || tile.type == 53 || tile.type == 57 || tile.type == 59 || tile.type == 123 || tile.type == 224 || tile.type == 397)
            {
                num8 += pickPower;
            }
            if (tile.type == 165 || Main.tileRope[tile.type] || tile.type == 199 || Main.tileMoss[tile.type])
            {
                num8 = 100;
            }
            if (hitTile.AddDamage(tileId, num8, updateAmount: false) >= 100 && (tile.type == 2 || tile.type == 23 || tile.type == 60 || tile.type == 70 || tile.type == 109 || tile.type == 199 || Main.tileMoss[tile.type]))
            {
                num8 = 0;
            }
            if (tile.type == 128 || tile.type == 269)
            {
                if (tile.frameX == 18 || tile.frameX == 54)
                {
                    x--;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameX >= 100)
                {
                    num8            = 0;
                    Main.blockMouse = true;
                }
            }
            if (tile.type == 334)
            {
                if (tile.frameY == 0)
                {
                    y++;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameY == 36)
                {
                    y--;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                int  j     = tile.frameX;
                bool flag3 = j >= 5000;
                bool flag2 = false;
                if (!flag3)
                {
                    int num7 = j / 18;
                    num7 %= 3;
                    x    -= num7;
                    tile  = Main.tile[x, y];
                    if (tile.frameX >= 5000)
                    {
                        flag3 = true;
                    }
                }
                if (flag3)
                {
                    j = tile.frameX;
                    int num5 = 0;
                    while (j >= 5000)
                    {
                        j -= 5000;
                        num5++;
                    }
                    if (num5 != 0)
                    {
                        flag2 = true;
                    }
                }
                if (flag2)
                {
                    num8            = 0;
                    Main.blockMouse = true;
                }
            }
            if (!Terraria.WorldGen.CanKillTile(x, y))
            {
                num8 = 0;
            }
            if (hitTile.AddDamage(tileId, num8) >= 100)
            {
                AchievementsHelper.CurrentlyMining = true;
                hitTile.Clear(tileId);
                if (Main.netMode == 1 && Main.tileContainer[Main.tile[x, y].type])
                {
                    WorldGen.AutoPicker.KillTile2(autoPicker, x, y, fail: true);
                    NetMessage.SendData(17, -1, -1, null, 0, x, y, 1f);
                    if (Main.tile[x, y].type == 21 || (Main.tile[x, y].type >= 470 && TileID.Sets.BasicChest[Main.tile[x, y].type]))
                    {
                        NetMessage.SendData(34, -1, -1, null, 1, x, y);
                    }
                    if (Main.tile[x, y].type == 467)
                    {
                        NetMessage.SendData(34, -1, -1, null, 5, x, y);
                    }
                    if (TileLoader.IsDresser(Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, null, 3, x, y);
                    }
                    if (Main.tile[x, y].type >= 470 && TileID.Sets.BasicChest[Main.tile[x, y].type])
                    {
                        NetMessage.SendData(34, -1, -1, null, 101, x, y, 0f, 0, Main.tile[x, y].type);
                    }
                    if (Main.tile[x, y].type >= 470 && TileLoader.IsDresser(Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, null, 103, x, y, 0f, 0, Main.tile[x, y].type);
                    }
                }
                else
                {
                    int  num4 = y;
                    bool num9 = Main.tile[x, num4].active();
                    WorldGen.AutoPicker.KillTile2(autoPicker, x, num4);
                    if (num9 && !Main.tile[x, num4].active())
                    {
                        AchievementsHelper.HandleMining();
                    }
                    if (Main.netMode == 1)
                    {
                        NetMessage.SendData(17, -1, -1, null, 0, x, num4);
                    }
                }
                AchievementsHelper.CurrentlyMining = false;
            }
            else
            {
                WorldGen.AutoPicker.KillTile2(autoPicker, x, y, fail: true);
                if (Main.netMode == 1)
                {
                    NetMessage.SendData(17, -1, -1, null, 0, x, y, 1f);
                }
            }
            if (num8 != 0)
            {
                hitTile.Prune();
            }
        }
Exemplo n.º 11
0
        public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
        {
            Tile tile     = Main.tile[i, j];
            Tile tile2    = Main.tile[i, j - 1];
            Tile tile3    = Main.tile[i, j + 1];
            int  tileType = tile.type;

            if (!WorldGen.noTileActions && tile.active() && (tileType == Type))
            {
                if (Main.netMode == NetmodeID.SinglePlayer)
                {
                    if (tile3 != null && !tile3.active())
                    {
                        bool flag18 = !(tile2.active() && (TileID.Sets.BasicChest[tile2.type] || TileID.Sets.BasicChestFake[tile2.type] || tile2.type == 323 || TileLoader.IsDresser(tile2.type)));
                        if (flag18)
                        {
                            int damage         = 10;
                            int projectileType = 0;
                            if (tileType == Type)
                            {
                                projectileType = ItemProjectileID;
                                damage         = 0;
                            }
                            tile.ClearTile();
                            int num77 = Projectile.NewProjectile(i * 16 + 8, j * 16 + 8, 0f, 0.41f, projectileType, damage, 0f, Main.myPlayer, 0f, 0f);
                            Main.projectile[num77].ai[0] = 1f;
                            WorldGen.SquareTileFrame(i, j, true);
                        }
                    }
                }
                else if (Main.netMode == NetmodeID.Server && tile3 != null && !tile3.active())
                {
                    bool flag19 = !(tile2.active() && (TileID.Sets.BasicChest[tile2.type] || TileID.Sets.BasicChestFake[tile2.type] || tile2.type == 323 || TileLoader.IsDresser(tile2.type)));
                    if (flag19)
                    {
                        int damage2        = 10;
                        int projectileType = 0;
                        if (tileType == Type)
                        {
                            projectileType = ItemProjectileID;
                            damage2        = 0;
                        }

                        tile.active(false);
                        bool flag20 = false;
                        for (int m = 0; m < 1000; m++)
                        {
                            if (Main.projectile[m].active && Main.projectile[m].owner == Main.myPlayer && Main.projectile[m].type == projectileType && Math.Abs(Main.projectile[m].timeLeft - 3600) < 60 && Main.projectile[m].Distance(new Vector2(i * 16 + 8, j * 16 + 10)) < 4f)
                            {
                                flag20 = true;
                                break;
                            }
                        }
                        if (!flag20)
                        {
                            int num79 = Projectile.NewProjectile(i * 16 + 8, j * 16 + 8, 0f, 2.5f, projectileType, damage2, 0f, Main.myPlayer, 0f, 0f);
                            Main.projectile[num79].velocity.Y = 0.5f;
                            Projectile expr_7AAA_cp_0 = Main.projectile[num79];
                            expr_7AAA_cp_0.position.Y       += 2f;
                            Main.projectile[num79].netUpdate = true;
                        }
                        NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None);
                        WorldGen.SquareTileFrame(i, j, true);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 12
0
        public override void Explosion()
        {
            if (Main.player[projectile.owner].EE().BombardEmblem)
            {
                return;
            }
            Vector2 position = projectile.Center;

            for (int x = -radius; x <= radius; x++)     //Starts on the X Axis on the left
            {
                for (int y = -radius; y <= radius; y++) //Starts on the Y Axis on the top
                {
                    int xPosition = (int)(x + position.X / 16.0f);
                    int yPosition = (int)(y + position.Y / 16.0f);

                    Tile tile = Framing.GetTileSafely(xPosition, yPosition);

                    if (Math.Sqrt(x * x + y * y) <= radius + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Circle
                    {
                        ushort tileP = tile.type;
                        if (!CanBreakTile(tileP, pickPower)) //Unbreakable CheckForUnbreakableTiles(tile) ||
                        {
                        }
                        else //Breakable
                        {
                            if (CanBreakTiles) //User preferences dictates if bombs can break tiles
                            {
                                if (!TileID.Sets.BasicChest[Main.tile[xPosition, yPosition - 1].type] && !TileLoader.IsDresser(Main.tile[xPosition, yPosition - 1].type))
                                {
                                    tile.ClearTile();
                                    tile.active(false);
                                }
                                if (CanBreakWalls)
                                {
                                    WorldGen.KillWall(xPosition, yPosition, false);                //This destroys Walls
                                }
                            }
                        }
                    }
                }
            }
        }
        //Explosion
        #region Explosion
        /// <summary>
        /// Takes the projectiles radius attribute in place of passing variables
        /// Creates a circular explosion in the radius defined
        /// Efficient but most blocks don't drop due to optimization methods
        /// </summary>
        public virtual void Explosion()
        {
            // x and y are the tile offset of the current tile relative to the player
            // i and j are the true tile cords relative to 0,0 in the world
            Player player = Main.player[projectile.owner];

            if (pickPower < -1)
            {
                return;
            }
            if (player.EE().BombardEmblem)
            {
                return;
            }

            Vector2 position = new Vector2(projectile.Center.X / 16f, projectile.Center.Y / 16f);    // Converts to tile cords for convenience

            radius = (int)((radius + player.EE().RadiusBonus) * player.EE().RadiusMulti);
            for (int x = -radius;
                 x <= radius;
                 x++)
            {
                //int x = (int)(i + position.X);
                for (int y = -radius;
                     y <= radius;
                     y++)
                {
                    //int y = (int)(j + position.Y);
                    int i = (int)(x + position.X);
                    int j = (int)(y + position.Y);
                    if (!WorldGen.InWorld(i, j))
                    {
                        continue;
                    }
                    if (Math.Sqrt(x * x + y * y) <= radius + 0.5) //Circle
                    {
                        Tile tile = Framing.GetTileSafely(i, j);

                        if (!WorldGen.TileEmpty(i, j) && tile.active())
                        {
                            if (!CanBreakTile(tile.type, pickPower))
                            {
                                continue;
                            }
                            //if (!CanBreakTiles) continue;
                            // Using KillTile is laggy, use ClearTile when working with larger tile sets    (also stops sound spam)
                            // But it must be done on outside tiles to ensure propper updates so use it only on outermost tiles
                            if (Math.Abs(x) >= radius - 1 || Math.Abs(y) >= radius - 1 || Terraria.ID.TileID.Sets.Ore[tile.type])
                            {
                                int type = tile.type;
                                WorldGen.KillTile((int)(i), (int)(j), false, false, false);

                                if (Main.netMode == NetmodeID.MultiplayerClient) //update if in mp
                                {
                                    WorldGen.SquareTileFrame(i, j, true);        //Updates Area
                                    NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)i, (float)j, 0f, 0, 0, 0);
                                }

                                if (player.EE().DropOresTwice&& Main.rand.NextFloat() <= player.EE().dropChanceOre)  //chance to drop 2 ores
                                {
                                    WorldGen.PlaceTile(i, j, type);
                                    WorldGen.KillTile((int)(i), (int)(j), false, false, false);

                                    if (Main.netMode == NetmodeID.MultiplayerClient)
                                    {
                                        WorldGen.SquareTileFrame(i, j, true); //Updates Area
                                        NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)i, (float)j, 0f, 0, 0, 0);
                                    }
                                }
                            }

                            else
                            {
                                if (!TileID.Sets.BasicChest[Main.tile[i, j - 1].type] && !TileLoader.IsDresser(Main.tile[i, j - 1].type) && Main.tile[i, j - 1].type != 26)
                                {
                                    tile.ClearTile();
                                    tile.active(false);

                                    if (Main.netMode == NetmodeID.MultiplayerClient)
                                    {
                                        WorldGen.SquareTileFrame(i, j, true); //Updates Area
                                        NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)i, (float)j, 0f, 0, 0, 0);
                                    }
                                }

                                if (tile.liquid == Tile.Liquid_Water || tile.liquid == Tile.Liquid_Lava || tile.liquid == Tile.Liquid_Honey)
                                {
                                    WorldGen.SquareTileFrame(i, j, true);
                                }
                            }
                        }
                    }
                }
            }
        }
        public override void Explosion()
        {
            Vector2 position = projectile.Center;

            int x = 0;
            int y = 0;

            int width  = 100; //Explosion Width
            int height = 20;  //Explosion Height

            for (y = height - 1; y >= 0; y--)
            {
                for (x = -width; x < width; x++)
                {
                    int xPosition = (int)(x + position.X / 16.0f);
                    int yPosition = (int)(-y + position.Y / 16.0f);

                    if (!WorldGen.InWorld(xPosition, yPosition))
                    {
                        continue;
                    }

                    Tile tile = Framing.GetTileSafely(xPosition, yPosition);

                    if (WorldGen.InWorld(xPosition, yPosition) && tile.active()) //Circle
                    {
                        if (!CanBreakTile(tile.type, pickPower))                 //Unbreakable CheckForUnbreakableTiles(tile) ||
                        {
                        }
                        else //Breakable
                        {
                            if (!TileID.Sets.BasicChest[Main.tile[xPosition, yPosition - 1].type] && !TileLoader.IsDresser(Main.tile[xPosition, yPosition - 1].type) && Main.tile[xPosition, yPosition - 1].type != 26)
                            {
                                tile.ClearTile();
                                tile.active(false);
                            }

                            if (tile.liquid == Tile.Liquid_Water || tile.liquid == Tile.Liquid_Lava || tile.liquid == Tile.Liquid_Honey)
                            {
                                WorldGen.SquareTileFrame(xPosition, yPosition, true);
                            }

                            if (Main.netMode == NetmodeID.MultiplayerClient)
                            {
                                WorldGen.SquareTileFrame(xPosition, yPosition, true); //Updates Area
                                NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)xPosition, (float)yPosition, 0f, 0, 0, 0);
                            }
                        }

                        if (CanBreakWalls)
                        {
                            WorldGen.KillWall(xPosition, yPosition, false);
                            WorldGen.KillWall(xPosition + 1, yPosition + 1, false); //get the last bit
                        }
                    }
                }
                width++; //Increments width to make stairs on each end
            }
        }
Exemplo n.º 15
0
        public override void Explosion()
        {
            // x and y are the tile offset of the current tile relative to the player
            // i and j are the true tile cords relative to 0,0 in the world
            Player player = Main.player[projectile.owner];

            if (pickPower < -1)
            {
                return;
            }
            if (player.EE().BombardEmblem)
            {
                return;
            }

            Vector2 position = new Vector2(player.Center.X / 16f, player.Center.Y / 16f);    // Converts to tile cords for convenience

            radius = (int)((radius + player.EE().RadiusBonus) * player.EE().RadiusMulti);
            for (int x = -radius;
                 x <= radius;
                 x++)
            {
                //int x = (int)(i + position.X);
                for (int y = -radius;
                     y <= radius;
                     y++)
                {
                    //int y = (int)(j + position.Y);
                    int i = (int)(x + position.X);
                    int j = (int)(y + position.Y);
                    if (!WorldGen.InWorld(i, j))
                    {
                        continue;
                    }
                    if (Math.Sqrt(x * x + y * y) <= radius + 0.5) //Circle
                    {
                        //Main.NewText($"({i}, {j})");
                        //Dust dust = Dust.NewDustDirect(new Vector2(i, j), 1, 1, 54);
                        //dust.noGravity = true;
                        if (!WorldGen.TileEmpty(i, j))
                        {
                            if (!CanBreakTile(Main.tile[i, j].type, pickPower))
                            {
                                continue;
                            }
                            if (!CanBreakTiles)
                            {
                                continue;
                            }
                            // Using KillTile is laggy, use ClearTile when working with larger tile sets    (also stops sound spam)
                            // But it must be done on outside tiles to ensure propper updates so use it only on outermost tiles
                            if (Math.Abs(x) >= radius - 1 || Math.Abs(y) >= radius - 1)
                            {
                                WorldGen.KillTile((int)(i), (int)(j), false, false, false);
                            }
                            else
                            {
                                if (!TileID.Sets.BasicChest[Main.tile[i, j - 1].type] && !TileLoader.IsDresser(Main.tile[i, j - 1].type))
                                {
                                    Main.tile[i, j].ClearTile();
                                    Main.tile[i, j].active(false);
                                }
                            }
                            //
                        }

                        if (CanBreakWalls)
                        {
                            //WorldGen.KillWall((int) (i), (int) (j));
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void AddNuclearWaste(int radius, Vector2 position, int spawnChance, int surfaceTile, int subSurfaceTile)
        {
            for (int x = -radius; x <= radius; x++)     //Starts on the X Axis on the left
            {
                for (int y = -radius; y <= radius; y++) //Starts on the Y Axis on the top
                {
                    int xPosition = (int)(x + position.X / 16.0f);
                    int yPosition = (int)(y + position.Y / 16.0f);


                    if (Math.Sqrt(x * x + y * y) <= radius - 1 + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Circle
                    {
                        Main.tile[xPosition, yPosition].liquid = Tile.Liquid_Water;
                        WorldGen.SquareTileFrame(xPosition, yPosition, true);
                    }
                    else if (Math.Sqrt(x * x + y * y) <= radius + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Circle
                    {
                        Main.tile[xPosition, yPosition].liquid = Tile.Liquid_Water;
                        WorldGen.SquareTileFrame(xPosition, yPosition, true);

                        ushort tile = Main.tile[xPosition, yPosition].type;
                        if (!CanBreakTile(tile, pickPower))                //Unbreakable CheckForUnbreakableTiles(tile) ||
                        {
                            if (!WorldGen.TileEmpty(xPosition, yPosition)) //Runs when a tile is not equal empty
                            {
                                if (Main.rand.Next(10) < spawnChance)
                                {
                                    if (!TileID.Sets.BasicChest[Main.tile[xPosition, yPosition - 1].type] && !TileLoader.IsDresser(Main.tile[xPosition, yPosition - 1].type))
                                    {
                                        Main.tile[xPosition, yPosition].ClearTile();
                                        Main.tile[xPosition, yPosition].active(false);
                                    }
                                    if (WorldGen.TileEmpty(xPosition + 1, yPosition) || WorldGen.TileEmpty(xPosition - 1, yPosition) || WorldGen.TileEmpty(xPosition, yPosition + 1) || WorldGen.TileEmpty(xPosition, yPosition - 1))
                                    {
                                        WorldGen.PlaceTile(xPosition, yPosition, surfaceTile);
                                    }
                                    else
                                    {
                                        WorldGen.PlaceTile(xPosition, yPosition, subSurfaceTile);
                                    }
                                }
                            }
                        }
                        else //Breakable
                        {
                            if (!WorldGen.TileEmpty(xPosition, yPosition)) //Runs when a tile is not equal empty
                            {
                                if (Main.rand.Next(10) < spawnChance)
                                {
                                    if (!TileID.Sets.BasicChest[Main.tile[xPosition, yPosition - 1].type] && !TileLoader.IsDresser(Main.tile[xPosition, yPosition - 1].type))
                                    {
                                        Main.tile[xPosition, yPosition].ClearTile();
                                        Main.tile[xPosition, yPosition].active(false);
                                    }
                                    if (WorldGen.TileEmpty(xPosition + 1, yPosition) || WorldGen.TileEmpty(xPosition - 1, yPosition) || WorldGen.TileEmpty(xPosition, yPosition + 1) || WorldGen.TileEmpty(xPosition, yPosition - 1))
                                    {
                                        WorldGen.PlaceTile(xPosition, yPosition, surfaceTile);
                                    }
                                    else
                                    {
                                        WorldGen.PlaceTile(xPosition, yPosition, subSurfaceTile);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
        private void CreateExplosion(Vector2 position, int radius)
        {
            //position = new Vector2(projectile.Center.X / 16f, projectile.Center.Y / 16f);    // Converts to tile cords for convenience

            for (int x = -radius;
                 x <= radius;
                 x++)
            {
                //int x = (int)(i + position.X);
                for (int y = -radius;
                     y <= radius;
                     y++)
                {
                    //int y = (int)(j + position.Y);
                    int i = (int)(x + position.X / 16);
                    int j = (int)(y + position.Y / 16);
                    if (!WorldGen.InWorld(i, j))
                    {
                        continue;
                    }
                    if (Math.Sqrt(x * x + y * y) <= radius + 0.5) //Circle
                    {
                        Tile tile = Framing.GetTileSafely(i, j);

                        if (!WorldGen.TileEmpty(i, j) && tile.active())
                        {
                            if (!CanBreakTile(tile.type, pickPower))
                            {
                                continue;
                            }
                            if (!CanBreakTiles)
                            {
                                continue;
                            }
                            // Using KillTile is laggy, use ClearTile when working with larger tile sets    (also stops sound spam)
                            // But it must be done on outside tiles to ensure propper updates so use it only on outermost tiles
                            if (Math.Abs(x) >= radius - 1 || Math.Abs(y) >= radius - 1)
                            {
                                WorldGen.KillTile((int)(i), (int)(j), false, false, false);
                            }
                            else
                            {
                                if (!TileID.Sets.BasicChest[Main.tile[i, j - 1].type] && !TileLoader.IsDresser(Main.tile[i, j - 1].type))
                                {
                                    tile.ClearTile();
                                    tile.active(false);
                                }

                                if (tile.liquid == Tile.Liquid_Water || tile.liquid == Tile.Liquid_Lava || tile.liquid == Tile.Liquid_Honey)
                                {
                                    Main.tile[i, j].liquid = Tile.Liquid_Water;
                                    WorldGen.SquareTileFrame(i, j, true);
                                }
                            }
                        }
                    }
                }
            }

            int depth = 8; //Sets the depth of the waste

            for (int x = depth + 1; x > 0; x--)
            {
                if (x == depth + 1)
                {
                    AddNuclearWaste(radius++, position, x, ModContent.TileType <NuclearWasteSurfaceTile>(), ModContent.TileType <NuclearWasteSurfaceTile>());
                }
                else
                {
                    AddNuclearWaste(radius++, position, x, ModContent.TileType <NuclearWasteSurfaceTile>(), ModContent.TileType <NuclearWasteSubSurfaceTile>());
                }
            }
        }
Exemplo n.º 18
0
        public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
        {
            if (WorldGen.noTileActions)
            {
                return(true);
            }

            Tile above   = Main.tile[i, j - 1];
            Tile below   = Main.tile[i, j + 1];
            bool canFall = false;

            if (below == null || below.active())
            {
                canFall = false;
            }

            if (above.active() && (TileID.Sets.BasicChest[above.type] || TileID.Sets.BasicChestFake[above.type] || above.type == TileID.Trees || TileLoader.IsDresser(above.type)))
            {
                canFall = false;
            }

            if (canFall)
            {
                // Set the projectile type to The404SnowProjectile
                int   projectileType = ModContent.ProjectileType <The404SandProjectile>();
                float positionX      = i * 16 + 8;
                float positionY      = j * 16 + 8;

                if (Main.netMode == NetmodeID.SinglePlayer)
                {
                    Main.tile[i, j].ClearTile();
                    int proj = Projectile.NewProjectile(positionX, positionY, 0f, 0.41f, projectileType, 10, 0f, Main.myPlayer);
                    Main.projectile[proj].ai[0] = 1f;
                    WorldGen.SquareTileFrame(i, j);
                }
                else if (Main.netMode == NetmodeID.Server)
                {
                    Main.tile[i, j].active(false);
                    bool spawnProj = true;

                    for (int k = 0; k < 1000; k++)
                    {
                        Projectile otherProj = Main.projectile[k];

                        if (otherProj.active && otherProj.owner == Main.myPlayer && otherProj.type == projectileType && Math.Abs(otherProj.timeLeft - 3600) < 60 && otherProj.Distance(new Vector2(positionX, positionY)) < 4f)
                        {
                            spawnProj = false;
                            break;
                        }
                    }

                    if (spawnProj)
                    {
                        int proj = Projectile.NewProjectile(positionX, positionY, 0f, 2.5f, projectileType, 10, 0f, Main.myPlayer);
                        Main.projectile[proj].velocity.Y  = 0.5f;
                        Main.projectile[proj].position.Y += 2f;
                        Main.projectile[proj].netUpdate   = true;
                    }

                    NetMessage.SendTileSquare(-1, i, j, 1);
                    WorldGen.SquareTileFrame(i, j);
                }
                return(false);
            }
            return(true);
        }
Exemplo n.º 19
0
        public void MineBlock(int x, int y, int pickPower, Chest chest, HitTile hitTile)
        {
            hitTile.UpdatePosition(Main.tile[x, y].type, x, y);
            int  num    = 0;
            int  tileId = hitTile.HitObject(x, y, 1);
            Tile tile   = Main.tile[x, y];

            if (Main.tileNoFail[(int)tile.type])
            {
                num = 100;
            }
            if (Main.tileDungeon[(int)tile.type] || tile.type == 25 || tile.type == 58 || tile.type == 117 || tile.type == 203)
            {
                num += pickPower / 2;
            }
            else if (tile.type == 48 || tile.type == 232)
            {
                num += pickPower / 4;
            }
            else if (tile.type == 226)
            {
                num += pickPower / 4;
            }
            else if (tile.type == 107 || tile.type == 221)
            {
                num += pickPower / 2;
            }
            else if (tile.type == 108 || tile.type == 222)
            {
                num += pickPower / 3;
            }
            else if (tile.type == 111 || tile.type == 223)
            {
                num += pickPower / 4;
            }
            else if (tile.type == 211)
            {
                num += pickPower / 5;
            }
            else
            {
                TileLoader.MineDamage(pickPower, ref num);
            }
            if (tile.type == 211 && pickPower < 200)
            {
                num = 0;
            }
            if ((tile.type == 25 || tile.type == 203) && pickPower < 65)
            {
                num = 0;
            }
            else if (tile.type == 117 && pickPower < 65)
            {
                num = 0;
            }
            else if (tile.type == 37 && pickPower < 50)
            {
                num = 0;
            }
            else if (tile.type == 404 && pickPower < 65)
            {
                num = 0;
            }
            else if ((tile.type == 22 || tile.type == 204) && (double)y > Main.worldSurface && pickPower < 55)
            {
                num = 0;
            }
            else if (tile.type == 56 && pickPower < 65)
            {
                num = 0;
            }
            else if (tile.type == 58 && pickPower < 65)
            {
                num = 0;
            }
            else if ((tile.type == 226 || tile.type == 237) && pickPower < 210)
            {
                num = 0;
            }
            else if (Main.tileDungeon[(int)tile.type] && pickPower < 65)
            {
                if ((double)x < (double)Main.maxTilesX * 0.35 || (double)x > (double)Main.maxTilesX * 0.65)
                {
                    num = 0;
                }
            }
            else if (tile.type == 107 && pickPower < 100)
            {
                num = 0;
            }
            else if (tile.type == 108 && pickPower < 110)
            {
                num = 0;
            }
            else if (tile.type == 111 && pickPower < 150)
            {
                num = 0;
            }
            else if (tile.type == 221 && pickPower < 100)
            {
                num = 0;
            }
            else if (tile.type == 222 && pickPower < 110)
            {
                num = 0;
            }
            else if (tile.type == 223 && pickPower < 150)
            {
                num = 0;
            }
            else
            {
                TileLoader.PickPowerCheck(tile, pickPower, ref num);
            }
            if (tile.type == 147 || tile.type == 0 || tile.type == 40 || tile.type == 53 || tile.type == 57 || tile.type == 59 || tile.type == 123 || tile.type == 224 || tile.type == 397)
            {
                num += pickPower;
            }
            if (tile.type == 165 || Main.tileRope[(int)tile.type] || tile.type == 199 || Main.tileMoss[(int)tile.type])
            {
                num = 100;
            }
            if (hitTile.AddDamage(tileId, num, false) >= 100 && (tile.type == 2 || tile.type == 23 || tile.type == 60 || tile.type == 70 || tile.type == 109 || tile.type == 199 || Main.tileMoss[(int)tile.type]))
            {
                num = 0;
            }
            if (tile.type == 128 || tile.type == 269)
            {
                if (tile.frameX == 18 || tile.frameX == 54)
                {
                    x--;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameX >= 100)
                {
                    num             = 0;
                    Main.blockMouse = true;
                }
            }
            if (tile.type == 334)
            {
                if (tile.frameY == 0)
                {
                    y++;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                if (tile.frameY == 36)
                {
                    y--;
                    tile = Main.tile[x, y];
                    hitTile.UpdatePosition(tileId, x, y);
                }
                int  i     = (int)tile.frameX;
                bool flag  = i >= 5000;
                bool flag2 = false;
                if (!flag)
                {
                    int num2 = i / 18;
                    num2 %= 3;
                    x    -= num2;
                    tile  = Main.tile[x, y];
                    if (tile.frameX >= 5000)
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    i = (int)tile.frameX;
                    int num3 = 0;
                    while (i >= 5000)
                    {
                        i -= 5000;
                        num3++;
                    }
                    if (num3 != 0)
                    {
                        flag2 = true;
                    }
                }
                if (flag2)
                {
                    num             = 0;
                    Main.blockMouse = true;
                }
            }
            if (!WorldGen.CanKillTile(x, y))
            {
                num = 0;
            }
            if (hitTile.AddDamage(tileId, num, true) >= 100)
            {
                hitTile.Clear(tileId);
                if (Main.netMode == 2 && Main.tileContainer[(int)Main.tile[x, y].type])
                {
                    WorldGen.KillTile(x, y, true, false, false);
                    NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)y, 1f, 0, 0, 0);
                    if (TileLoader.IsChest((int)Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, "", 1, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                    if (TileLoader.IsDresser((int)Main.tile[x, y].type))
                    {
                        NetMessage.SendData(34, -1, -1, "", 3, (float)x, (float)y, 0f, 0, 0, 0);
                    }
                }
                else
                {
                    int  num4  = y;
                    bool flag3 = Main.tile[x, num4].active();
                    WorldGen.KillTile(x, num4, false, false, false);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)num4, 0f, 0, 0, 0);
                    }
                }
            }
            else
            {
                WorldGen.KillTile(x, y, true, false, false);
                if (Main.netMode == 2)
                {
                    NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)y, 1f, 0, 0, 0);
                }
            }
            if (num != 0)
            {
                hitTile.Prune();
            }
        }
Exemplo n.º 20
0
        public static bool TileFrame_Sand(int i, int j, int projType)
        {
            if (WorldGen.noTileActions)
            {
                return(true);
            }
            Tile above   = Main.tile[i, j - 1];
            Tile below   = Main.tile[i, j + 1];
            bool canFall = true;

            if (below == null || below.active())
            {
                canFall = false;
            }
            if (above.active() && (TileID.Sets.BasicChest[above.type] || TileID.Sets.BasicChestFake[above.type] || above.type == TileID.PalmTree || TileLoader.IsDresser(above.type)))
            {
                canFall = false;
            }
            if (canFall)
            {
                int   type = projType;
                float posX = i * 16 + 8;
                float posY = j * 16 + 8;
                if (Main.netMode == 0)
                {
                    Main.tile[i, j].ClearTile();
                    int proj = Projectile.NewProjectile(posX, posY, 0f, 0.41f, type, 10, 0f, Main.myPlayer, 0f, 0f);
                    Main.projectile[proj].ai[0] = 1f;
                    WorldGen.SquareTileFrame(i, j, true);
                }
                else if (Main.netMode == 2)
                {
                    Main.tile[i, j].active(false);
                    bool spawnProj = true;
                    for (int k = 0; k < 1000; k++)
                    {
                        Projectile otherProj = Main.projectile[k];
                        if (otherProj.active && otherProj.owner == Main.myPlayer && otherProj.type == type && Math.Abs(otherProj.timeLeft - 3600) < 60 && otherProj.Distance(new Vector2(posX, posY)) < 4f)
                        {
                            spawnProj = false;
                            break;
                        }
                    }
                    if (spawnProj)
                    {
                        int proj = Projectile.NewProjectile(posX, posY, 0f, 2.5f, type, 10, 0f, Main.myPlayer, 0f, 0f);
                        Main.projectile[proj].velocity.Y  = 0.5f;
                        Main.projectile[proj].position.Y += 2f;
                        Main.projectile[proj].netUpdate   = true;
                    }
                    NetMessage.SendTileSquare(-1, i, j, 1);
                    WorldGen.SquareTileFrame(i, j, true);
                }
                return(false);
            }
            return(true);
        }
Exemplo n.º 21
0
        /*public override void NearbyEffects(int i, int j, bool closer)
         * {
         *  delay = 0;
         * }*/

        public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
        {
            //if(delay == 0)
            //{

            /*if (delay == 1)
             * {
             *  return true;
             * }*/
            if (WorldGen.noTileActions)
            {
                return(true);
            }
            delay = 1;
            Tile above      = Main.tile[i, j - 1];//checks for chests / other tiles that need tiles below them
            Tile below      = Main.tile[i, j + 1];
            Tile belowLeft  = Main.tile[i - 1, j + 1];
            Tile belowRight = Main.tile[i + 1, j + 1];

            bool canFall      = true; //desides if the below 3 bools matter
            bool canFallDown  = true; //falldown overrides the below 2
            bool canFallLeft  = true;
            bool canFallRight = true;

            if (below == null || below.active())
            {
                canFallDown = false;
            }
            if (belowLeft == null || belowLeft.active())
            {
                canFallLeft = false;
            }
            if (belowRight == null || belowRight.active())
            {
                canFallRight = false;
            }
            if (above.active() && (TileID.Sets.BasicChest[above.type] || TileID.Sets.BasicChestFake[above.type] || TileLoader.IsDresser(above.type)))
            {
                canFall = false;
            }
            if (canFall)
            {
                if (canFallDown)
                {
                    Main.tile[i, j].ClearTile();
                    WorldGen.PlaceTile(i, j + 1, ModContent.TileType <Tiles.GravelGreen>(), true, true);
                    //if (Main.netMode == 2)
                    //{
                    WorldGen.SquareTileFrame(i, j, true);
                    NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None);
                    //}
                }
                else
                {
                    switch (WorldGen.genRand.Next(1))     //choose to fall down left or down right
                    {
                    case 0:
                        if (canFallLeft)
                        {
                            Main.tile[i, j].ClearTile();
                            WorldGen.PlaceTile(i - 1, j + 1, ModContent.TileType <Tiles.GravelGreen>(), true, true);
                            //if (Main.netMode == 2)
                            //{
                            WorldGen.SquareTileFrame(i, j, true);
                            NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None);
                            //}
                        }
                        else if (canFallRight)
                        {
                            Main.tile[i, j].ClearTile();
                            WorldGen.PlaceTile(i + 1, j + 1, ModContent.TileType <Tiles.GravelGreen>(), true, true);
                            //if (Main.netMode == 2)
                            //{
                            WorldGen.SquareTileFrame(i, j, true);
                            NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None);
                            //}
                        }
                        break;

                    case 1:
                        if (canFallRight)
                        {
                            Main.tile[i, j].ClearTile();
                            WorldGen.PlaceTile(i + 1, j + 1, ModContent.TileType <Tiles.GravelGreen>(), true, true);
                            //if (Main.netMode == 2)
                            //{
                            WorldGen.SquareTileFrame(i, j, true);
                            NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None);
                            //}
                        }
                        else if (canFallLeft)
                        {
                            Main.tile[i, j].ClearTile();
                            WorldGen.PlaceTile(i - 1, j + 1, ModContent.TileType <Tiles.GravelGreen>(), true, true);
                            //if (Main.netMode == 2)
                            //{
                            WorldGen.SquareTileFrame(i, j, true);
                            NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None);
                            //}
                        }
                        break;
                    }
                }

                /*if(canFallDown || canFallLeft || canFallRight)
                 * {
                 *  WorldGen.KillTile(i, j, false, false, true);
                 *  if (Main.netMode == 2)
                 *  {
                 *      WorldGen.SquareTileFrame(i, j, true);
                 *      NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None);
                 *  }
                 * }*/
                //return false;
            }
            //}

            //delay = 0;
            //return true;
            return(false);//disabled cus annoying
            //}

            /*else
             * {
             *  delay += 1;
             *  return true;
             * }*/
        }