예제 #1
0
 private static bool CanKillTile(int i, int j)
 {
     if (Main.tile[i, j] != null && Main.tile[i, j].active())
     {
         if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404)
         {
             return(false);
         }
         if (!Main.hardMode && Main.tile[i, j].type == 58)
         {
             return(false);
         }
         if (!TileLoader.CanExplode(i, j))
         {
             return(false);
         }
         return(true);
     }
     return(false);
 }
예제 #2
0
        public override void AI()
        {
            projectile.direction       = projectile.velocity.X > 0 ? 1 : -1;
            projectile.spriteDirection = projectile.direction;
            projectile.rotation        = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + (projectile.direction == -1 ? 3.14f : 0);;
            projectile.frameCounter++;
            if (projectile.frameCounter >= 4)
            {
                projectile.frameCounter = 0;
                projectile.frame        = (projectile.frame + 1) % 4;
            }
            int minTileX = (int)(projectile.position.X / 16f);
            int maxTileX = (int)((projectile.position.X + projectile.width) / 16f);
            int minTileY = (int)(projectile.position.Y / 16f);
            int maxTileY = (int)((projectile.position.Y + projectile.height) / 16f);

            if (minTileX < 0)
            {
                minTileX = 0;
            }
            if (maxTileX > Main.maxTilesX)
            {
                maxTileX = Main.maxTilesX;
            }
            if (minTileY < 0)
            {
                minTileY = 0;
            }
            if (maxTileY > Main.maxTilesY)
            {
                maxTileY = Main.maxTilesY;
            }
            for (int i = minTileX; i <= maxTileX; i++)
            {
                for (int j = minTileY; j <= maxTileY; j++)
                {
                    bool canKillTile = true;
                    if (Main.tile[i, j] != null && Main.tile[i, j].active())
                    {
                        if (Main.tileDungeon[Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211)
                        {
                            canKillTile = false;
                        }
                        if (!Main.hardMode && Main.tile[i, j].type == 58)
                        {
                            canKillTile = false;
                        }
                        if (!TileLoader.CanExplode(i, j))
                        {
                            canKillTile = false;
                        }
                        if (canKillTile)
                        {
                            WorldGen.KillTile(i, j, false, false, false);
                            if (!Main.tile[i, j].active() && Main.netMode != 0)
                            {
                                NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                            }
                        }
                    }
                }
            }
        }
        public static void Explode(float posX, float posY, float radius = 3, bool wallDamage = true)
        {
            int xBegin = (int)(posX / 16f - radius);
            int xEnd   = (int)(posX / 16f + radius);
            int yBegin = (int)(posY / 16f - radius);
            int yEnd   = (int)(posY / 16f + radius);

            if (xBegin < 0)
            {
                xBegin = 0;
            }
            if (xEnd > Main.maxTilesX)
            {
                xEnd = Main.maxTilesX;
            }
            if (yBegin < 0)
            {
                yBegin = 0;
            }
            if (yEnd > Main.maxTilesY)
            {
                yEnd = Main.maxTilesY;
            }
            bool breakWall = false;

            if (wallDamage)
            {
                for (int x = xBegin; x <= xEnd; x++)
                {
                    for (int y = yBegin; y <= yEnd; y++)
                    {
                        float  deltaX = Math.Abs((float)x - posX / 16f);
                        float  deltaY = Math.Abs((float)y - posY / 16f);
                        double dist   = Math.Sqrt((double)(deltaX * deltaX + deltaY * deltaY));
                        if (dist < (double)radius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0)
                        {
                            breakWall = true;
                            break;
                        }
                    }
                }
            }
            AchievementsHelper.CurrentlyMining = true;
            for (int x = xBegin; x <= xEnd; x++)
            {
                for (int y = yBegin; y <= yEnd; y++)
                {
                    float  deltaX = Math.Abs((float)x - posX / 16f);
                    float  deltaY = Math.Abs((float)y - posY / 16f);
                    double dist   = Math.Sqrt((double)(deltaX * deltaX + deltaY * deltaY));
                    if (dist < (double)radius)
                    {
                        bool destroyTile = true;
                        if (Main.tile[x, y] != null && Main.tile[x, y].active())
                        {
                            destroyTile = true;
                            ushort tile = Main.tile[x, y].type;
                            if (Main.tileDungeon[(int)tile] || tile == 88 || tile == 21 || tile == 26 || tile == 107 || tile == 108 || tile == 111 || tile == 226 || tile == 237 || tile == 221 || tile == 222 || tile == 223 || tile == 211 || tile == 404)
                            {
                                destroyTile = false;
                            }
                            //patch file: x, y
                            if (!Main.hardMode && tile == 58)
                            {
                                destroyTile = false;
                                //patch file: x, y
                            }
                            if (!TileLoader.CanExplode(x, y))
                            {
                                destroyTile = false;
                            }
                            if (destroyTile)
                            {
                                WorldGen.KillTile(x, y, false, false, false);
                                if (!Main.tile[x, y].active() && Main.netMode != 0)
                                {
                                    NetMessage.SendData(17, -1, -1, null, 0, (float)x, (float)y, 0f, 0, 0, 0);
                                }
                            }
                        }
                        if (destroyTile && breakWall)
                        {
                            for (int wallX = x - 1; wallX <= x + 1; wallX++)
                            {
                                for (int wallY = y - 1; wallY <= y + 1; wallY++)
                                {
                                    if (Main.tile[wallX, wallY] != null && Main.tile[wallX, wallY].wall > 0)
                                    {
                                        WorldGen.KillWall(wallX, wallY, false);
                                        if (Main.tile[wallX, wallY].wall == 0 && Main.netMode != 0)
                                        {
                                            NetMessage.SendData(17, -1, -1, null, 2, (float)wallX, (float)wallY, 0f, 0, 0, 0);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            AchievementsHelper.CurrentlyMining = false;
        }
예제 #4
0
        private void Explode()
        {
            Player player = Main.player[projectile.owner]; //get player

            // Play explosion sound
            Main.PlaySound(SoundID.Item14, projectile.position);

            // Smoke Dust spawn
            for (int i = 0; i < 50; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X + (projectile.width / 4), projectile.position.Y + (projectile.height / 4)), projectile.width / 2, projectile.height / 2, 31, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 1.4f;
            }

            // Fire Dust spawn
            for (int i = 0; i < 80; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X + (projectile.width / 4), projectile.position.Y + (projectile.height / 4)), projectile.width / 2, projectile.height / 2, 6, 0f, 0f, 100, default(Color), 3f);
                Main.dust[dustIndex].noGravity = true;
                Main.dust[dustIndex].velocity *= 5f;
                dustIndex = Dust.NewDust(new Vector2(projectile.position.X + (projectile.width / 4), projectile.position.Y + (projectile.height / 4)), projectile.width / 2, projectile.height / 2, 6, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 3f;
            }

            // Large Smoke Gore spawn
            for (int g = 0; g < 2; g++)
            {
                int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (projectile.width / 2) - 24f, projectile.position.Y + (projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (projectile.width / 2) - 24f, projectile.position.Y + (projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (projectile.width / 2) - 24f, projectile.position.Y + (projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (projectile.width / 2) - 24f, projectile.position.Y + (projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
            }

            //how many blocks to explode
            int explosionRadius = projectile.width / 16 / 4;

            //find min/max x/y tiles in circle around projectile
            int minTileX = (int)(player.Center.X / 16f - (float)explosionRadius);
            int maxTileX = (int)(player.Center.X / 16f + (float)explosionRadius);
            int minTileY = (int)(player.Center.Y / 16f - (float)explosionRadius);
            int maxTileY = (int)(player.Center.Y / 16f + (float)explosionRadius);

            //clamp tile range inside world
            if (minTileX < 0)
            {
                minTileX = 0;
            }
            if (maxTileX > Main.maxTilesX)
            {
                maxTileX = Main.maxTilesX;
            }
            if (minTileY < 0)
            {
                minTileY = 0;
            }
            if (maxTileY > Main.maxTilesY)
            {
                maxTileY = Main.maxTilesY;
            }

            bool canKillWalls = false;

            //only get walls inside a circle
            for (int x = minTileX; x <= maxTileX; x++)
            {
                for (int y = minTileY; y <= maxTileY; y++)
                {
                    float  diffX    = Math.Abs((float)x - player.Center.X / 16f);
                    float  diffY    = Math.Abs((float)y - player.Center.Y / 16f);
                    double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                    if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0)
                    {
                        canKillWalls = true;
                        break;
                    }
                }
            }

            //only get tiles inside a circle
            for (int i = minTileX; i <= maxTileX; i++)
            {
                for (int j = minTileY; j <= maxTileY; j++)
                {
                    float  diffX          = Math.Abs((float)i - player.Center.X / 16f);
                    float  diffY          = Math.Abs((float)j - player.Center.Y / 16f);
                    double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                    if (distanceToTile < (double)explosionRadius)
                    {
                        bool canKillTile = true;
                        if (Main.tile[i, j] != null && Main.tile[i, j].active())
                        {
                            canKillTile = true;
                            if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404)
                            {
                                canKillTile = false;    //cant kill dungeon walls
                            }
                            if (!Main.hardMode && Main.tile[i, j].type == 58)
                            {
                                canKillTile = false;    //cant kill ? walls
                            }
                            if (!TileLoader.CanExplode(i, j))
                            {
                                canKillTile = false;    //cant kill unexplodable walls
                            }
                            if (canKillTile)
                            {
                                //kill tile
                                WorldGen.KillTile(i, j, false, false, false);
                                if (!Main.tile[i, j].active() && Main.netMode != 0)
                                {
                                    NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                                }
                            }
                        }
                        if (canKillTile)
                        {
                            for (int x = i - 1; x <= i + 1; x++)
                            {
                                for (int y = j - 1; y <= j + 1; y++)
                                {
                                    if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall))
                                    {
                                        WorldGen.KillWall(x, y, false);
                                        if (Main.tile[x, y].wall == 0 && Main.netMode != 0)
                                        {
                                            NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
 private static void tileBreaker(Projectile projectile, int tileExplode)
 {
     if (projectile.owner == Main.myPlayer && tileExplode > 0)
     {
         int num702 = (int)(projectile.position.X / 16f - (float)tileExplode);
         int num703 = (int)(projectile.position.X / 16f + (float)tileExplode);
         int num704 = (int)(projectile.position.Y / 16f - (float)tileExplode);
         int num705 = (int)(projectile.position.Y / 16f + (float)tileExplode);
         if (num702 < 0)
         {
             num702 = 0;
         }
         if (num703 > Main.maxTilesX)
         {
             num703 = Main.maxTilesX;
         }
         if (num704 < 0)
         {
             num704 = 0;
         }
         if (num705 > Main.maxTilesY)
         {
             num705 = Main.maxTilesY;
         }
         bool flag3 = false;
         int  num9;
         for (int num706 = num702; num706 <= num703; num706 = num9 + 1)
         {
             for (int num707 = num704; num707 <= num705; num707 = num9 + 1)
             {
                 float  num708 = Math.Abs((float)num706 - projectile.position.X / 16f);
                 float  num709 = Math.Abs((float)num707 - projectile.position.Y / 16f);
                 double num710 = Math.Sqrt((double)(num708 * num708 + num709 * num709));
                 if (num710 < (double)tileExplode && Main.tile[num706, num707] != null && Main.tile[num706, num707].wall == 0)
                 {
                     flag3 = true;
                     break;
                 }
                 num9 = num707;
             }
             num9 = num706;
         }
         AchievementsHelper.CurrentlyMining = true;
         for (int num711 = num702; num711 <= num703; num711 = num9 + 1)
         {
             for (int num712 = num704; num712 <= num705; num712 = num9 + 1)
             {
                 float  num713 = Math.Abs((float)num711 - projectile.position.X / 16f);
                 float  num714 = Math.Abs((float)num712 - projectile.position.Y / 16f);
                 double num715 = Math.Sqrt((double)(num713 * num713 + num714 * num714));
                 if (num715 < (double)tileExplode)
                 {
                     bool flag4 = true;
                     if (Main.tile[num711, num712] != null && Main.tile[num711, num712].active())
                     {
                         flag4 = true;
                         if (Main.tileDungeon[(int)Main.tile[num711, num712].type] || Main.tile[num711, num712].type == 21 || Main.tile[num711, num712].type == 26 || Main.tile[num711, num712].type == 107 || Main.tile[num711, num712].type == 108 || Main.tile[num711, num712].type == 111 || Main.tile[num711, num712].type == 226 || Main.tile[num711, num712].type == 237 || Main.tile[num711, num712].type == 221 || Main.tile[num711, num712].type == 222 || Main.tile[num711, num712].type == 223 || Main.tile[num711, num712].type == 211 || Main.tile[num711, num712].type == 404)
                         {
                             flag4 = false;
                         }
                         if (!Main.hardMode && Main.tile[num711, num712].type == 58)
                         {
                             flag4 = false;
                         }
                         if (!TileLoader.CanExplode(num711, num712))
                         {
                             flag4 = false;
                         }
                         if (flag4)
                         {
                             WorldGen.KillTile(num711, num712, false, false, false);
                             if (!Main.tile[num711, num712].active() && Main.netMode != 0)
                             {
                                 NetMessage.SendData(17, -1, -1, null, 0, (float)num711, (float)num712, 0f, 0, 0, 0);
                             }
                         }
                     }
                     if (flag4)
                     {
                         for (int num716 = num711 - 1; num716 <= num711 + 1; num716 = num9 + 1)
                         {
                             for (int num717 = num712 - 1; num717 <= num712 + 1; num717 = num9 + 1)
                             {
                                 if ((Main.tile[num716, num717] != null && Main.tile[num716, num717].wall > 0) & flag3)
                                 {
                                     WorldGen.KillWall(num716, num717, false);
                                     if (Main.tile[num716, num717].wall == 0 && Main.netMode != 0)
                                     {
                                         NetMessage.SendData(17, -1, -1, null, 2, (float)num716, (float)num717, 0f, 0, 0, 0);
                                     }
                                 }
                                 num9 = num717;
                             }
                             num9 = num716;
                         }
                     }
                 }
                 num9 = num712;
             }
             num9 = num711;
         }
         AchievementsHelper.CurrentlyMining = false;
     }
 }
예제 #6
0
        public override void Kill(int timeLeft)
        {
            // Play explosion sound
            Main.PlaySound(mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/Custom/WarheadSound"), projectile.position);
            // Smoke Dust spawn
            for (int i = 0; i < 50; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 1.4f;
            }
            // Fire Dust spawn
            for (int i = 0; i < 80; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3f);
                Main.dust[dustIndex].noGravity = true;
                Main.dust[dustIndex].velocity *= 5f;
                dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 3f;
            }
            // Large Smoke Gore spawn
            for (int g = 0; g < 2; g++)
            {
                int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
            }
            // reset size to normal width and height.
            projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
            projectile.width      = 10;
            projectile.height     = 10;
            projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);

            // TODO, tmodloader helper method
            {
                int explosionRadius = 75;
                int minTileX        = (int)(projectile.position.X / 16f - (float)explosionRadius);
                int maxTileX        = (int)(projectile.position.X / 16f + (float)explosionRadius);
                int minTileY        = (int)(projectile.position.Y / 16f - (float)explosionRadius);
                int maxTileY        = (int)(projectile.position.Y / 16f + (float)explosionRadius);

                // fix to not alter blocks outside of the world
                if (minTileX < 0)
                {
                    minTileX = 0;
                }
                if (maxTileX > Main.maxTilesX)
                {
                    maxTileX = Main.maxTilesX;
                }
                if (minTileY < 0)
                {
                    minTileY = 0;
                }
                if (maxTileY > Main.maxTilesY)
                {
                    maxTileY = Main.maxTilesY;
                }
                bool canKillWalls = false;
                for (int x = minTileX; x <= maxTileX; x++)
                {
                    for (int y = minTileY; y <= maxTileY; y++)
                    {
                        float  diffX    = Math.Abs((float)x - projectile.position.X / 16f);
                        float  diffY    = Math.Abs((float)y - projectile.position.Y / 16f);
                        double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0)
                        {
                            canKillWalls = true;
                            break;
                        }
                    }
                }
                AchievementsHelper.CurrentlyMining = true;
                for (int i = minTileX; i <= maxTileX; i++)
                {
                    for (int j = minTileY; j <= maxTileY; j++)
                    {
                        float  diffX          = Math.Abs((float)i - projectile.position.X / 16f);
                        float  diffY          = Math.Abs((float)j - projectile.position.Y / 16f);
                        double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distanceToTile < (double)explosionRadius)
                        {
                            bool canKillTile = true;
                            if (Main.tile[i, j] != null && Main.tile[i, j].active())
                            {
                                canKillTile = true;
                                //dungeon blocks
                                if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404)
                                {
                                    canKillTile = false;
                                }
                                if (!Main.hardMode && Main.tile[i, j].type == 58)                                 //hardmode allow destruction of Hellstone
                                {
                                    canKillTile = false;
                                }
                                if (!TileLoader.CanExplode(i, j))                                 //verify if tile can fundamentally be blown up or not
                                {
                                    canKillTile = false;
                                }
                                if (canKillTile)
                                {
                                    WorldGen.KillTile(i, j, false, false, false);
                                    if (!Main.tile[i, j].active() && Main.netMode != NetmodeID.SinglePlayer)
                                    {
                                        NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                                    }
                                }
                            }
                            if (canKillTile)
                            {
                                for (int x = i - 1; x <= i + 1; x++)
                                {
                                    for (int y = j - 1; y <= j + 1; y++)
                                    {
                                        if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall))
                                        {
                                            WorldGen.KillWall(x, y, false);
                                            if (Main.tile[x, y].wall == 0 && Main.netMode != NetmodeID.SinglePlayer)
                                            {
                                                NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                AchievementsHelper.CurrentlyMining = false;
            }
        }
예제 #7
0
파일: TBMUtils.cs 프로젝트: HellGoesOn/TBM
        public static void Explode(Vector2 position, int explosionRadius = 5)
        {
            int minTileX = (int)(position.X / 16f - (float)explosionRadius);
            int maxTileX = (int)(position.X / 16f + (float)explosionRadius);
            int minTileY = (int)(position.Y / 16f - (float)explosionRadius);
            int maxTileY = (int)(position.Y / 16f + (float)explosionRadius);

            if (minTileX < 0)
            {
                minTileX = 0;
            }
            if (maxTileX > Main.maxTilesX)
            {
                maxTileX = Main.maxTilesX;
            }
            if (minTileY < 0)
            {
                minTileY = 0;
            }
            if (maxTileY > Main.maxTilesY)
            {
                maxTileY = Main.maxTilesY;
            }
            bool canKillWalls = false;

            for (int x = minTileX; x <= maxTileX; x++)
            {
                for (int y = minTileY; y <= maxTileY; y++)
                {
                    float  diffX    = Math.Abs((float)x - position.X / 16f);
                    float  diffY    = Math.Abs((float)y - position.Y / 16f);
                    double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                    if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0)
                    {
                        canKillWalls = true;
                        break;
                    }
                }
            }
            AchievementsHelper.CurrentlyMining = true;
            for (int i = minTileX; i <= maxTileX; i++)
            {
                for (int j = minTileY; j <= maxTileY; j++)
                {
                    float  diffX          = Math.Abs((float)i - position.X / 16f);
                    float  diffY          = Math.Abs((float)j - position.Y / 16f);
                    double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                    if (distanceToTile < (double)explosionRadius)
                    {
                        bool canKillTile = true;
                        if (Main.tile[i, j] != null && Main.tile[i, j].active())
                        {
                            canKillTile = true;
                            if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404)
                            {
                                canKillTile = false;
                            }
                            if (!Main.hardMode && Main.tile[i, j].type == 58)
                            {
                                canKillTile = false;
                            }
                            if (!TileLoader.CanExplode(i, j))
                            {
                                canKillTile = false;
                            }
                            if (canKillTile)
                            {
                                WorldGen.KillTile(i, j, false, false, false);
                                if (!Main.tile[i, j].active() && Main.netMode != 0)
                                {
                                    NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                                }
                            }
                        }
                        if (canKillTile)
                        {
                            for (int x = i - 1; x <= i + 1; x++)
                            {
                                for (int y = j - 1; y <= j + 1; y++)
                                {
                                    if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall))
                                    {
                                        WorldGen.KillWall(x, y, false);
                                        if (Main.tile[x, y].wall == 0 && Main.netMode != 0)
                                        {
                                            NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            AchievementsHelper.CurrentlyMining = false;
        }
예제 #8
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (projectile.timeLeft == 10 || projectile.penetrate == 1)
            {
                projectile.position   += new Vector2(-50, -50);
                projectile.width       = 150;
                projectile.height      = 150;
                projectile.timeLeft    = 9;
                projectile.alpha       = 255;
                projectile.penetrate   = -1;
                projectile.tileCollide = false;
                projectile.friendly    = false;
                projectile.hostile     = true;
            }
            if (projectile.timeLeft == 9)
            {
                Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14);
            }
            if (projectile.timeLeft < 10)
            {
                projectile.velocity = new Vector2(0, 0);
            }

            if (projectile.timeLeft == 3)
            {
                projectile.width     = 22;
                projectile.height    = 32;
                projectile.position += new Vector2(60, 60);
            }
            // Adapted a tiny bit from ExampleMod's Example Explosive.
            if (projectile.timeLeft == 1)
            {
                int explosionRadius = 6;
                int minTileX        = (int)(projectile.position.X / 16f - (float)explosionRadius);
                int maxTileX        = (int)(projectile.position.X / 16f + (float)explosionRadius);
                int minTileY        = (int)(projectile.position.Y / 16f - (float)explosionRadius);
                int maxTileY        = (int)(projectile.position.Y / 16f + (float)explosionRadius);
                if (minTileX < 0)
                {
                    minTileX = 0;
                }
                if (maxTileX > Main.maxTilesX)
                {
                    maxTileX = Main.maxTilesX;
                }
                if (minTileY < 0)
                {
                    minTileY = 0;
                }
                if (maxTileY > Main.maxTilesY)
                {
                    maxTileY = Main.maxTilesY;
                }
                bool canKillWalls = false;
                for (int x = minTileX; x <= maxTileX; x++)
                {
                    for (int y = minTileY; y <= maxTileY; y++)
                    {
                        float  diffX    = Math.Abs((float)x - projectile.position.X / 16f);
                        float  diffY    = Math.Abs((float)y - projectile.position.Y / 16f);
                        double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0)
                        {
                            canKillWalls = true;
                            break;
                        }
                    }
                }
                AchievementsHelper.CurrentlyMining = true;
                for (int i = minTileX; i <= maxTileX; i++)
                {
                    for (int j = minTileY; j <= maxTileY; j++)
                    {
                        float  diffX          = Math.Abs((float)i - projectile.position.X / 16f);
                        float  diffY          = Math.Abs((float)j - projectile.position.Y / 16f);
                        double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distanceToTile < (double)explosionRadius)
                        {
                            bool canKillTile = true;
                            if (Main.tile[i, j] != null && Main.tile[i, j].active())
                            {
                                canKillTile = true;
                                if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404)
                                {
                                    canKillTile = false;
                                }
                                if (!Main.hardMode && Main.tile[i, j].type == 58)
                                {
                                    canKillTile = false;
                                }
                                if (!TileLoader.CanExplode(i, j))
                                {
                                    canKillTile = false;
                                }
                                if (canKillTile)
                                {
                                    WorldGen.KillTile(i, j, false, false, false);
                                    if (!Main.tile[i, j].active() && Main.netMode != 0)
                                    {
                                        NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                                    }
                                }
                            }
                            if (canKillTile)
                            {
                                for (int x = i - 1; x <= i + 1; x++)
                                {
                                    for (int y = j - 1; y <= j + 1; y++)
                                    {
                                        if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall))
                                        {
                                            WorldGen.KillWall(x, y, false);
                                            if (Main.tile[x, y].wall == 0 && Main.netMode != 0)
                                            {
                                                NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                AchievementsHelper.CurrentlyMining = false;
            }
            for (int i = 0; i < 2; i++)
            {
                int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 63, 0f, 0f, 50, default(Color), 1f);
                Main.dust[dust].noGravity = true;
            }
            Lighting.AddLight(projectile.Center, 0.4f, 0.4f, 0.6f);
        }
        public override void AI()
        {
            if (projectile.owner == Main.myPlayer && projectile.timeLeft == 297)
            {
                projectile.position   = projectile.Center;
                projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
                projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
                projectile.width      = 0;
                projectile.height     = 0;
                projectile.Center     = projectile.position;
                projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
                projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
            }
            else if (projectile.owner == Main.myPlayer && projectile.timeLeft > 297)
            {
                projectile.tileCollide = false;
                // change the hitbox size, centered about the original projectile center. This makes the projectile damage enemies during the explosion.
                projectile.position = projectile.Center;
                //projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
                //projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
                projectile.width  = 300;
                projectile.height = 300;
                playerCenterX     = projectile.position.X;
                playerCenterY     = projectile.position.Y;
                projectile.Center = projectile.position;
                //projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
                //projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);

                // Play explosion sound
                Main.PlaySound(SoundID.Item14, projectile.position);
                Main.PlaySound(SoundID.Item14, projectile.position);
                Main.PlaySound(SoundID.Item14, projectile.position);

                // Smoke Dust spawn
                for (int i = 0; i < 50; i++)
                {
                    int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f);
                    Main.dust[dustIndex].velocity *= 1.4f;
                }
                // Fire Dust spawn
                for (int i = 0; i < 80; i++)
                {
                    int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3f);
                    Main.dust[dustIndex].noGravity = true;
                    Main.dust[dustIndex].velocity *= 5f;
                    dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 2f);
                    Main.dust[dustIndex].velocity *= 3f;
                }
                // Large Smoke Gore spawn
                for (int g = 0; g < 2; g++)
                {
                    int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                    Main.gore[goreIndex].scale      = 1.5f;
                    Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                    Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                    goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                    Main.gore[goreIndex].scale      = 1.5f;
                    Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                    Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                    goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                    Main.gore[goreIndex].scale      = 1.5f;
                    Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                    Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
                    goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                    Main.gore[goreIndex].scale      = 1.5f;
                    Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                    Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
                }

                {
                    int explosionRadius = 15;

                    int minTileX = (int)(playerCenterX / 16f - (float)explosionRadius);
                    int maxTileX = (int)(playerCenterX / 16f + (float)explosionRadius);
                    int minTileY = (int)(playerCenterY / 16f - (float)explosionRadius);
                    int maxTileY = (int)(playerCenterY / 16f + (float)explosionRadius);
                    if (minTileX < 0)
                    {
                        minTileX = 0;
                    }
                    if (maxTileX > Main.maxTilesX)
                    {
                        maxTileX = Main.maxTilesX;
                    }
                    if (minTileY < 0)
                    {
                        minTileY = 0;
                    }
                    if (maxTileY > Main.maxTilesY)
                    {
                        maxTileY = Main.maxTilesY;
                    }
                    bool canKillWalls = false;
                    for (int x = minTileX; x <= maxTileX; x++)
                    {
                        for (int y = minTileY; y <= maxTileY; y++)
                        {
                            float  diffX    = Math.Abs((float)x - playerCenterX / 16f);
                            float  diffY    = Math.Abs((float)y - playerCenterY / 16f);
                            double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                            if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0)
                            {
                                canKillWalls = true;
                                break;
                            }
                        }
                    }
                    AchievementsHelper.CurrentlyMining = true;
                    for (int i = minTileX; i <= maxTileX; i++)
                    {
                        for (int j = minTileY; j <= maxTileY; j++)
                        {
                            float  diffX          = Math.Abs((float)i - playerCenterX / 16f);
                            float  diffY          = Math.Abs((float)j - playerCenterY / 16f);
                            double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                            if (distanceToTile < (double)explosionRadius)
                            {
                                bool canKillTile = true;
                                if (Main.tile[i, j] != null && Main.tile[i, j].active())
                                {
                                    canKillTile = true;
                                    if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404)
                                    {
                                        canKillTile = false;
                                    }
                                    if (!Main.hardMode && Main.tile[i, j].type == 58)
                                    {
                                        canKillTile = false;
                                    }
                                    if (!TileLoader.CanExplode(i, j))
                                    {
                                        canKillTile = false;
                                    }
                                    if (canKillTile)
                                    {
                                        WorldGen.KillTile(i, j, false, false, false);
                                        if (!Main.tile[i, j].active() && Main.netMode != NetmodeID.SinglePlayer)
                                        {
                                            NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                                        }
                                    }
                                }
                                if (canKillTile)
                                {
                                    for (int x = i - 1; x <= i + 1; x++)
                                    {
                                        for (int y = j - 1; y <= j + 1; y++)
                                        {
                                            if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall))
                                            {
                                                WorldGen.KillWall(x, y, false);
                                                if (Main.tile[x, y].wall == 0 && Main.netMode != NetmodeID.SinglePlayer)
                                                {
                                                    NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    AchievementsHelper.CurrentlyMining = false;
                }
            }

            return;
        }
예제 #10
0
        ////

        /// <summary>
        /// Indicates if a given tile cannot be destroyed by vanilla explosives.
        /// </summary>
        /// <param name="tileX"></param>
        /// <param name="tileY"></param>
        /// <returns></returns>
        public static bool IsNotVanillaBombable(int tileX, int tileY)
        {
            Tile tile = Framing.GetTileSafely(tileX, tileY);

            return(!TileLoader.CanExplode(tileX, tileY) || TileAttributeLibraries.IsNotVanillaBombableType(tile.type));
        }
예제 #11
0
        public override void Kill(int timeLeft)
        {
            Vector2 position = projectile.Center;

            Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Hallelujah"), (int)position.X, (int)position.Y);

            for (int i = 0; i < 50; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 1.4f;
            }

            for (int i = 0; i < 80; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.GoldFlame, 0f, 0f, 100, default(Color), 3f);
                Main.dust[dustIndex].noGravity = true;
                Main.dust[dustIndex].velocity *= 5f;
                dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.GoldFlame, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 3f;
            }

            for (int g = 0; g < 2; g++)
            {
                int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
            }

            projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
            projectile.width      = 15;
            projectile.height     = 15;
            projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);

            {
                int explosionRadius = 15;

                int minTileX = (int)(projectile.position.X / 16f - (float)explosionRadius);
                int maxTileX = (int)(projectile.position.X / 16f + (float)explosionRadius);
                int minTileY = (int)(projectile.position.Y / 16f - (float)explosionRadius);
                int maxTileY = (int)(projectile.position.Y / 16f + (float)explosionRadius);
                if (minTileX < 0)
                {
                    minTileX = 0;
                }
                if (maxTileX > Main.maxTilesX)
                {
                    maxTileX = Main.maxTilesX;
                }
                if (minTileY < 0)
                {
                    minTileY = 0;
                }
                if (maxTileY > Main.maxTilesY)
                {
                    maxTileY = Main.maxTilesY;
                }
                bool canKillWalls = false;
                for (int x = minTileX; x <= maxTileX; x++)
                {
                    for (int y = minTileY; y <= maxTileY; y++)
                    {
                        float  diffX    = Math.Abs((float)x - projectile.position.X / 16f);
                        float  diffY    = Math.Abs((float)y - projectile.position.Y / 16f);
                        double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0)
                        {
                            canKillWalls = true;
                            break;
                        }
                    }
                }
                AchievementsHelper.CurrentlyMining = true;
                for (int i = minTileX; i <= maxTileX; i++)
                {
                    for (int j = minTileY; j <= maxTileY; j++)
                    {
                        float  diffX          = Math.Abs((float)i - projectile.position.X / 16f);
                        float  diffY          = Math.Abs((float)j - projectile.position.Y / 16f);
                        double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distanceToTile < (double)explosionRadius)
                        {
                            bool canKillTile = true;
                            if (Main.tile[i, j] != null && Main.tile[i, j].active())
                            {
                                canKillTile = true;
                                if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404)
                                {
                                    canKillTile = false;
                                }
                                if (!Main.hardMode && Main.tile[i, j].type == 58)
                                {
                                    canKillTile = false;
                                }
                                if (!TileLoader.CanExplode(i, j))
                                {
                                    canKillTile = false;
                                }
                                if (canKillTile)
                                {
                                    WorldGen.KillTile(i, j, false, false, false);
                                    if (!Main.tile[i, j].active() && Main.netMode != 0)
                                    {
                                        NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                                    }
                                }
                            }
                            if (canKillTile)
                            {
                                for (int x = i - 1; x <= i + 1; x++)
                                {
                                    for (int y = j - 1; y <= j + 1; y++)
                                    {
                                        if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall))
                                        {
                                            WorldGen.KillWall(x, y, false);
                                            if (Main.tile[x, y].wall == 0 && Main.netMode != 0)
                                            {
                                                NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                AchievementsHelper.CurrentlyMining = false;
            }
        }
예제 #12
0
        public override void Kill(int timeLeft)
        {
            Main.PlaySound(SoundID.Item14, base.projectile.position);
            for (int i = 0; i < 50; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(base.projectile.position.X, base.projectile.position.Y), base.projectile.width, base.projectile.height, 31, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 1.4f;
            }
            for (int j = 0; j < 80; j++)
            {
                int dustIndex2 = Dust.NewDust(new Vector2(base.projectile.position.X, base.projectile.position.Y), base.projectile.width, base.projectile.height, 6, 0f, 0f, 100, default(Color), 3f);
                Main.dust[dustIndex2].noGravity = true;
                Main.dust[dustIndex2].velocity *= 5f;
                dustIndex2 = Dust.NewDust(new Vector2(base.projectile.position.X, base.projectile.position.Y), base.projectile.width, base.projectile.height, 6, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex2].velocity *= 3f;
            }
            for (int g = 0; g < 2; g++)
            {
                int goreIndex = Gore.NewGore(new Vector2(base.projectile.position.X + (float)(base.projectile.width / 2) - 24f, base.projectile.position.Y + (float)(base.projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(base.projectile.position.X + (float)(base.projectile.width / 2) - 24f, base.projectile.position.Y + (float)(base.projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
            }
            base.projectile.position.X = base.projectile.position.X + (float)(base.projectile.width / 2);
            base.projectile.position.Y = base.projectile.position.Y + (float)(base.projectile.height / 2);
            base.projectile.width      = 10;
            base.projectile.height     = 10;
            base.projectile.position.X = base.projectile.position.X - (float)(base.projectile.width / 2);
            base.projectile.position.Y = base.projectile.position.Y - (float)(base.projectile.height / 2);
            int  explosionRadius = 5;
            int  minTileX        = (int)(base.projectile.position.X / 16f - (float)explosionRadius);
            int  maxTileX        = (int)(base.projectile.position.X / 16f + (float)explosionRadius);
            int  minTileY        = (int)(base.projectile.position.Y / 16f - (float)explosionRadius);
            int  maxTileY        = (int)(base.projectile.position.Y / 16f + (float)explosionRadius);
            bool flag            = minTileX < 0;

            if (flag)
            {
                minTileX = 0;
            }
            bool flag2 = maxTileX > Main.maxTilesX;

            if (flag2)
            {
                maxTileX = Main.maxTilesX;
            }
            bool flag3 = minTileY < 0;

            if (flag3)
            {
                minTileY = 0;
            }
            bool flag4 = maxTileY > Main.maxTilesY;

            if (flag4)
            {
                maxTileY = Main.maxTilesY;
            }
            bool canKillWalls = false;

            for (int x = minTileX; x <= maxTileX; x++)
            {
                for (int y = minTileY; y <= maxTileY; y++)
                {
                    float  diffX    = Math.Abs((float)x - base.projectile.position.X / 16f);
                    float  diffY    = Math.Abs((float)y - base.projectile.position.Y / 16f);
                    double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                    bool   flag5    = distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0;
                    if (flag5)
                    {
                        canKillWalls = true;
                        break;
                    }
                }
            }
            for (int m = minTileX; m <= maxTileX; m++)
            {
                for (int n = minTileY; n <= maxTileY; n++)
                {
                    float  diffX3          = Math.Abs((float)m - base.projectile.position.X / 16f);
                    float  diffY3          = Math.Abs((float)n - base.projectile.position.Y / 16f);
                    double distanceToTile2 = Math.Sqrt((double)(diffX3 * diffX3 + diffY3 * diffY3));
                    bool   flag7           = distanceToTile2 < (double)explosionRadius;
                    if (flag7)
                    {
                        bool canKillTile = true;
                        bool flag8       = Main.tile[m, n] != null && Main.tile[m, n].active();
                        if (flag8)
                        {
                            canKillTile = true;
                            bool flag9 = Main.tileDungeon[(int)Main.tile[m, n].type] || Main.tile[m, n].type == 88 || Main.tile[m, n].type == 21 || Main.tile[m, n].type == 26 || Main.tile[m, n].type == 107 || Main.tile[m, n].type == 108 || Main.tile[m, n].type == 111 || Main.tile[m, n].type == 226 || Main.tile[m, n].type == 237 || Main.tile[m, n].type == 221 || Main.tile[m, n].type == 222 || Main.tile[m, n].type == 223 || Main.tile[m, n].type == 211 || Main.tile[m, n].type == 404;
                            if (flag9)
                            {
                                canKillTile = false;
                            }
                            bool flag10 = !Main.hardMode && Main.tile[m, n].type == 58;
                            if (flag10)
                            {
                                canKillTile = false;
                            }
                            bool flag11 = !TileLoader.CanExplode(m, n);
                            if (flag11)
                            {
                                canKillTile = false;
                            }
                            bool flag12 = canKillTile;
                            if (flag12)
                            {
                                WorldGen.KillTile(m, n, false, false, false);
                                bool flag13 = !Main.tile[m, n].active() && Main.netMode != NetmodeID.SinglePlayer;
                                if (flag13)
                                {
                                    NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)m, (float)n, 0f, 0, 0, 0);
                                }
                            }
                        }
                        bool flag14 = canKillTile;
                        if (flag14)
                        {
                            for (int x2 = m - 1; x2 <= m + 1; x2++)
                            {
                                for (int y2 = n - 1; y2 <= n + 1; y2++)
                                {
                                    bool flag15 = Main.tile[x2, y2] != null && Main.tile[x2, y2].wall > 0 && canKillWalls && WallLoader.CanExplode(x2, y2, (int)Main.tile[x2, y2].wall);
                                    if (flag15)
                                    {
                                        WorldGen.KillWall(x2, y2, false);
                                        bool flag16 = Main.tile[x2, y2].wall == 0 && Main.netMode != NetmodeID.SinglePlayer;
                                        if (flag16)
                                        {
                                            NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)x2, (float)y2, 0f, 0, 0, 0);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #13
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            //changes the frame of the projectile every 5 ticks
            if (++projectile.frameCounter >= 5) //change this number to change rate of change of frames
            {
                projectile.frameCounter = 0;
                if (++projectile.frame >= 15)
                {
                    projectile.frame = 0;
                }
            }

            //check explosion based on time left
            if (projectile.timeLeft < 400 && !hasExploded)
            {
                hasExploded = true;

                //shows bounds of explosion
                //each block is 16 pixels wide and tall
                int minX = (int)(projectile.position.X / 16f - (float)explosionRadius);
                int maxX = (int)(projectile.position.X / 16f + (float)explosionRadius);
                int minY = (int)(projectile.position.Y / 16f - (float)explosionRadius);
                int maxY = (int)(projectile.position.Y / 16f + (float)explosionRadius);

                //if we are at either edge of the world, set the min and max to 0 or maximum world size
                if (minX < 0)
                {
                    minX = 0;
                }
                if (maxX > Main.maxTilesX)
                {
                    maxX = Main.maxTilesX;
                }
                if (minY < 0)
                {
                    minY = 0;
                }
                if (maxY > Main.maxTilesY)
                {
                    maxY = Main.maxTilesY;
                }

                //Main.NewText(minX + " " + minY);
                //Main.NewText(maxX + " " + maxY);
                //Main.NewText(projectile.position.X/16f + " " + projectile.position.Y/16f);

                for (int x = minX; x <= maxX; x++)
                {
                    for (int y = minY; y <= maxY; y++)
                    {
                        //determines whether or not the player is within the radius of our explosion as our bonds create a square
                        float  diffX      = Math.Abs((float)x - projectile.position.X / 16f);
                        float  diffY      = Math.Abs((float)y - projectile.position.Y / 16f);
                        double distanceTo = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distanceTo <= explosionRadius)
                        {
                            bool canKillTile = true;

                            //if the tile is explodable or not
                            if (!TileLoader.CanExplode(x, y))
                            {
                                canKillTile = false;
                            }

                            if (canKillTile)
                            {
                                //what is going on here
                                WorldGen.KillTile(x, y, false, false, false);
                                if (!Main.tile[x, y].active() && Main.netMode != 0)
                                {
                                    NetMessage.SendData(17, -1, -1, null, 0, (float)x, (float)y, 0f, 0, 0, 0);
                                }
                            }
                        }
                    }
                }
            }

            if (hasExploded)
            {
                itemsUp = true;
                int itemsLength = Main.item.Length;
                //how far the pull reach is
                float pullRadius = (float)(explosionRadius * 2.5);

                //iterates through every item in the world and tries to attract it
                for (int i = 0; i < itemsLength; i++)
                {
                    float  xDiff       = (float)(Main.item[i].position.X / 16f - projectile.position.X / 16f);
                    float  yDiff       = (float)(Main.item[i].position.Y / 16f - projectile.position.Y / 16f);
                    double distanceToo = Math.Sqrt((double)(xDiff * xDiff + yDiff * yDiff));
                    if (distanceToo < pullRadius)
                    {
                        //determines the strength of the pull on an item
                        float rad, radAhead, gravity, moveX, moveY, normalizeScale;

                        //figure out the current degree to the item from the center of our object
                        if (xDiff < 0)
                        {
                            rad = (float)(Math.Atan(yDiff / xDiff) + Math.PI);
                        }
                        else if (yDiff > 0)
                        {
                            rad = (float)(Math.Atan(yDiff / xDiff));
                        }
                        else
                        {
                            rad = (float)(Math.Atan(yDiff / xDiff) + Math.PI * 2f);
                        }

                        radAhead = (float)(rad + 90f);

                        moveX = (float)((projectile.Center.X - 0) - Main.item[i].position.X - Math.Pow(speed, 2) * Math.Max(distanceToo, 2) * Math.Cos(radAhead));
                        moveY = (float)((projectile.Center.Y + 3) - Main.item[i].position.Y - Math.Pow(speed, 2) * distanceToo * Math.Sin(radAhead));

                        Main.item[i].velocity.X += moveX;
                        Main.item[i].velocity.Y += moveY;

                        normalizeScale = (float)(Math.Sqrt(Main.item[i].velocity.X * Main.item[i].velocity.X + Main.item[i].velocity.Y * Main.item[i].velocity.Y));

                        Main.item[i].velocity.X *= speed / normalizeScale;
                        Main.item[i].velocity.Y *= speed / normalizeScale;
                    }
                }
            }

            //below this line is the movement control for the projectile

            float slowDown = (float)(maxDistance * .15);

            //slows down projectile's horizontal movement until it is less than one, then completely stops it
            if (projectile.velocity.X > .2f || projectile.velocity.X < -.2f)
            {
                projectile.velocity.X -= (float)((1 * maxSpeed / slowDown) * (Math.Abs(projectile.velocity.X) / projectile.velocity.X));
            }
            else
            {
                projectile.velocity.X = 0f;
            }

            //slows down projectile's vertical movement until it is less than one, then completely stops it
            if (projectile.velocity.Y > .2f || projectile.velocity.Y < -.2f)
            {
                projectile.velocity.Y -= (float)((1 * maxSpeed / slowDown) * (Math.Abs(projectile.velocity.Y) / projectile.velocity.Y));
            }
            else
            {
                projectile.velocity.Y = 0f;
            }
        }
예제 #14
0
        public override void Kill(int timeLeft)
        {
            // Play explosion sound
            Main.PlaySound(SoundID.Item15, projectile.position);
            // Smoke Dust spawn
            for (int i = 0; i < 50; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 1.4f;
            }
            // Fire Dust spawn
            for (int i = 0; i < 80; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3f);
                Main.dust[dustIndex].noGravity = true;
                Main.dust[dustIndex].velocity *= 5f;
                dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 3f;
            }
            // Large Smoke Gore spawn
            for (int g = 0; g < 2; g++)
            {
                int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
            }
            // reset size to normal width and height.
            projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
            projectile.width      = 10;
            projectile.height     = 10;
            projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);

            // TODO, tmodloader helper method
            if (ModContent.GetInstance <Configs>().MobGriefing)
            {
                int explosionRadius = 8;
                //if (projectile.type == 29 || projectile.type == 470 || projectile.type == 637)
                {
                    explosionRadius = 8;
                }
                int minTileX = (int)(projectile.position.X / 16f - (float)explosionRadius);
                int maxTileX = (int)(projectile.position.X / 16f + (float)explosionRadius);
                int minTileY = (int)(projectile.position.Y / 16f - (float)explosionRadius);
                int maxTileY = (int)(projectile.position.Y / 16f + (float)explosionRadius);
                if (minTileX < 0)
                {
                    minTileX = 0;
                }
                if (maxTileX > Main.maxTilesX)
                {
                    maxTileX = Main.maxTilesX;
                }
                if (minTileY < 0)
                {
                    minTileY = 0;
                }
                if (maxTileY > Main.maxTilesY)
                {
                    maxTileY = Main.maxTilesY;
                }
                bool canKillWalls = false;
                for (int x = minTileX; x <= maxTileX; x++)
                {
                    for (int y = minTileY; y <= maxTileY; y++)
                    {
                        float  diffX    = Math.Abs((float)x - projectile.position.X / 16f);
                        float  diffY    = Math.Abs((float)y - projectile.position.Y / 16f);
                        double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0)
                        {
                            canKillWalls = true;
                            break;
                        }
                    }
                }
                AchievementsHelper.CurrentlyMining = true;
                for (int i = minTileX; i <= maxTileX; i++)
                {
                    for (int j = minTileY; j <= maxTileY; j++)
                    {
                        float  diffX          = Math.Abs((float)i - projectile.position.X / 16f);
                        float  diffY          = Math.Abs((float)j - projectile.position.Y / 16f);
                        double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distanceToTile < (double)explosionRadius)
                        {
                            bool canKillTile = true;
                            if (Main.tile[i, j] != null && Main.tile[i, j].active())
                            {
                                canKillTile = true;
                                if (!Main.hardMode && Main.tile[i, j].type == 58)
                                {
                                    canKillTile = false;
                                }
                                if (!TileLoader.CanExplode(i, j))
                                {
                                    canKillTile = false;
                                }
                                if (canKillTile)
                                {
                                    WorldGen.KillTile(i, j, false, false, false);
                                    if (!Main.tile[i, j].active() && Main.netMode != NetmodeID.SinglePlayer)
                                    {
                                        NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                                    }
                                }
                            }
                            if (canKillTile)
                            {
                                for (int x = i - 1; x <= i + 1; x++)
                                {
                                    for (int y = j - 1; y <= j + 1; y++)
                                    {
                                        if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall))
                                        {
                                            WorldGen.KillWall(x, y, false);
                                            if (Main.tile[x, y].wall == 0 && Main.netMode != NetmodeID.SinglePlayer)
                                            {
                                                NetMessage.SendData(MessageID.TileChange, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                AchievementsHelper.CurrentlyMining = false;
            }
            else
            {
                AchievementsHelper.CurrentlyMining = false;
            }
        }
예제 #15
0
        public override void Kill(int timeLeft)
        {
            // If we are the original projectile, spawn the 5 child projectiles
            if (projectile.ai[1] == 0)
            {
                for (int i = 0; i < 5; i++)
                {
                    // Random upward vector.
                    Vector2 vel = new Vector2(Main.rand.NextFloat(-3, 3), Main.rand.NextFloat(-10, -8));
                    Projectile.NewProjectile(projectile.Center, vel, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 0, 1);
                }
            }
            // Play explosion sound
            Main.PlaySound(SoundID.Item15, projectile.position);
            // Smoke Dust spawn
            for (int i = 0; i < 50; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 1.4f;
            }
            // Fire Dust spawn
            for (int i = 0; i < 80; i++)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3f);
                Main.dust[dustIndex].noGravity = true;
                Main.dust[dustIndex].velocity *= 5f;
                dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 2f);
                Main.dust[dustIndex].velocity *= 3f;
            }
            // Large Smoke Gore spawn
            for (int g = 0; g < 2; g++)
            {
                int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default(Vector2), Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
            }
            // reset size to normal width and height.
            projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
            projectile.width      = 10;
            projectile.height     = 10;
            projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);

            // TODO, tmodloader helper method
            {
                int explosionRadius = 3;
                //if (projectile.type == 29 || projectile.type == 470 || projectile.type == 637)
                {
                    explosionRadius = 7;
                }
                int minTileX = (int)(projectile.position.X / 16f - (float)explosionRadius);
                int maxTileX = (int)(projectile.position.X / 16f + (float)explosionRadius);
                int minTileY = (int)(projectile.position.Y / 16f - (float)explosionRadius);
                int maxTileY = (int)(projectile.position.Y / 16f + (float)explosionRadius);
                if (minTileX < 0)
                {
                    minTileX = 0;
                }
                if (maxTileX > Main.maxTilesX)
                {
                    maxTileX = Main.maxTilesX;
                }
                if (minTileY < 0)
                {
                    minTileY = 0;
                }
                if (maxTileY > Main.maxTilesY)
                {
                    maxTileY = Main.maxTilesY;
                }
                bool canKillWalls = false;
                for (int x = minTileX; x <= maxTileX; x++)
                {
                    for (int y = minTileY; y <= maxTileY; y++)
                    {
                        float  diffX    = Math.Abs((float)x - projectile.position.X / 16f);
                        float  diffY    = Math.Abs((float)y - projectile.position.Y / 16f);
                        double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0)
                        {
                            canKillWalls = true;
                            break;
                        }
                    }
                }
                AchievementsHelper.CurrentlyMining = true;
                for (int i = minTileX; i <= maxTileX; i++)
                {
                    for (int j = minTileY; j <= maxTileY; j++)
                    {
                        float  diffX          = Math.Abs((float)i - projectile.position.X / 16f);
                        float  diffY          = Math.Abs((float)j - projectile.position.Y / 16f);
                        double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distanceToTile < (double)explosionRadius)
                        {
                            bool canKillTile = true;
                            if (Main.tile[i, j] != null && Main.tile[i, j].active())
                            {
                                canKillTile = true;
                                if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404)
                                {
                                    canKillTile = false;
                                }
                                if (!Main.hardMode && Main.tile[i, j].type == 58)
                                {
                                    canKillTile = false;
                                }
                                if (!TileLoader.CanExplode(i, j))
                                {
                                    canKillTile = false;
                                }
                                if (canKillTile)
                                {
                                    WorldGen.KillTile(i, j, false, false, false);
                                    if (!Main.tile[i, j].active() && Main.netMode != 0)
                                    {
                                        NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                                    }
                                }
                            }
                            if (canKillTile)
                            {
                                for (int x = i - 1; x <= i + 1; x++)
                                {
                                    for (int y = j - 1; y <= j + 1; y++)
                                    {
                                        if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall))
                                        {
                                            WorldGen.KillWall(x, y, false);
                                            if (Main.tile[x, y].wall == 0 && Main.netMode != 0)
                                            {
                                                NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                AchievementsHelper.CurrentlyMining = false;
            }
        }
예제 #16
0
        public override void Kill(int timeLeft)
        {
            //Main.PlaySound(SoundID.Item14, projectile.position);
            switch (Main.rand.Next(4))
            {
            case 1:  Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Explode1"), projectile.position); break;

            case 2:  Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Explode2"), projectile.position); break;

            case 3:  Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Explode3"), projectile.position); break;

            default: Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Explode4"), projectile.position); break;
            }

            {
                projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
                projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
                projectile.width      = 32;
                projectile.height     = 32;
                projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
                projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
                int num4;
                for (int i = 0; i < 30; i++)
                {
                    int  index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 1.5f);
                    Dust dust  = Main.dust[index];
                    dust.velocity *= 1.4f;
                }
                for (int i = 0; i < 20; i++)
                {
                    int index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3.5f);
                    Main.dust[index].noGravity = true;
                    Dust dust = Main.dust[index];
                    dust.velocity *= 7f;
                    index          = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 1.5f);
                    dust           = Main.dust[index];
                    dust.velocity *= 3f;
                }
                for (int i = 0; i < 10; i++)
                {
                    int index = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 3.5f);
                    Main.dust[index].noGravity = true;
                    Dust dust = Main.dust[index];
                    dust.velocity *= 14f;
                    index          = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 1.5f);
                    dust           = Main.dust[index];
                    dust.velocity *= 7f;
                }
                for (int i = 0; i < 4; i++)
                {
                    float scaleFactor9 = 1.2f;
                    if (i <= 1)
                    {
                        scaleFactor9 = 2.4f;
                    }
                    Vector2 position48 = new Vector2(projectile.position.X, projectile.position.Y);
                    Vector2 vector     = default(Vector2);
                    int     index      = Gore.NewGore(position48, vector, Main.rand.Next(61, 64), 1f);
                    Gore    gore       = Main.gore[index];
                    gore.velocity *= scaleFactor9;
                    Gore gore110 = Main.gore[index];
                    gore110.velocity.X = gore110.velocity.X + 1f;
                    Gore gore111 = Main.gore[index];
                    gore111.velocity.Y = gore111.velocity.Y + 1f;
                    Vector2 position49 = new Vector2(projectile.position.X, projectile.position.Y);
                    vector         = default(Vector2);
                    index          = Gore.NewGore(position49, vector, Main.rand.Next(61, 64), 1f);
                    gore           = Main.gore[index];
                    gore.velocity *= scaleFactor9;
                    Gore gore112 = Main.gore[index];
                    gore112.velocity.X = gore112.velocity.X - 1f;
                    Gore gore113 = Main.gore[index];
                    gore113.velocity.Y = gore113.velocity.Y + 1f;
                    Vector2 position50 = new Vector2(projectile.position.X, projectile.position.Y);
                    vector         = default(Vector2);
                    index          = Gore.NewGore(position50, vector, Main.rand.Next(61, 64), 1f);
                    gore           = Main.gore[index];
                    gore.velocity *= scaleFactor9;
                    Gore gore114 = Main.gore[index];
                    gore114.velocity.X = gore114.velocity.X + 1f;
                    Gore gore115 = Main.gore[index];
                    gore115.velocity.Y = gore115.velocity.Y - 1f;
                    Vector2 position51 = new Vector2(projectile.position.X, projectile.position.Y);
                    vector         = default(Vector2);
                    index          = Gore.NewGore(position51, vector, Main.rand.Next(61, 64), 1f);
                    gore           = Main.gore[index];
                    gore.velocity *= scaleFactor9;
                    Gore gore116 = Main.gore[index];
                    gore116.velocity.X = gore116.velocity.X - 1f;
                    Gore gore117 = Main.gore[index];
                    gore117.velocity.Y = gore117.velocity.Y - 1f;
                }
            }

            {
                int explosionRadius = 8;
                int minTileX        = (int)(projectile.position.X / 16f - (float)explosionRadius);
                int maxTileX        = (int)(projectile.position.X / 16f + (float)explosionRadius);
                int minTileY        = (int)(projectile.position.Y / 16f - (float)explosionRadius);
                int maxTileY        = (int)(projectile.position.Y / 16f + (float)explosionRadius);
                if (minTileX < 0)
                {
                    minTileX = 0;
                }
                if (maxTileX > Main.maxTilesX)
                {
                    maxTileX = Main.maxTilesX;
                }
                if (minTileY < 0)
                {
                    minTileY = 0;
                }
                if (maxTileY > Main.maxTilesY)
                {
                    maxTileY = Main.maxTilesY;
                }
                bool canKillWalls = false;
                for (int x = minTileX; x <= maxTileX; x++)
                {
                    for (int y = minTileY; y <= maxTileY; y++)
                    {
                        float  diffX    = Math.Abs((float)x - projectile.position.X / 16f);
                        float  diffY    = Math.Abs((float)y - projectile.position.Y / 16f);
                        double distance = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distance < (double)explosionRadius && Main.tile[x, y] != null && Main.tile[x, y].wall == 0)
                        {
                            canKillWalls = true;
                            break;
                        }
                    }
                }
                for (int i = minTileX; i <= maxTileX; i++)
                {
                    for (int j = minTileY; j <= maxTileY; j++)
                    {
                        float  diffX          = Math.Abs((float)i - projectile.position.X / 16f);
                        float  diffY          = Math.Abs((float)j - projectile.position.Y / 16f);
                        double distanceToTile = Math.Sqrt((double)(diffX * diffX + diffY * diffY));
                        if (distanceToTile < (double)explosionRadius)
                        {
                            bool canKillTile = true;
                            if (Main.tile[i, j] != null && Main.tile[i, j].active())
                            {
                                canKillTile = true;
                                if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404)
                                {
                                    canKillTile = false;
                                }
                                if (!Main.hardMode && Main.tile[i, j].type == 58)
                                {
                                    canKillTile = false;
                                }
                                if (!TileLoader.CanExplode(i, j))
                                {
                                    canKillTile = false;
                                }
                                if (canKillTile)
                                {
                                    WorldGen.KillTile(i, j, false, false, false);
                                    if (!Main.tile[i, j].active() && Main.netMode != 0)
                                    {
                                        NetMessage.SendData(17, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0);
                                    }
                                }
                            }
                            if (canKillTile)
                            {
                                for (int x = i - 1; x <= i + 1; x++)
                                {
                                    for (int y = j - 1; y <= j + 1; y++)
                                    {
                                        if (Main.tile[x, y] != null && Main.tile[x, y].wall > 0 && canKillWalls && WallLoader.CanExplode(x, y, Main.tile[x, y].wall))
                                        {
                                            WorldGen.KillWall(x, y, false);
                                            if (Main.tile[x, y].wall == 0 && Main.netMode != 0)
                                            {
                                                NetMessage.SendData(17, -1, -1, null, 2, (float)x, (float)y, 0f, 0, 0, 0);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #17
0
        public static bool IsNotVanillaBombable(int tile_x, int tile_y)
        {
            Tile tile = Framing.GetTileSafely(tile_x, tile_y);

            return(!TileLoader.CanExplode(tile_x, tile_y) || TileHelpers.IsNotVanillaBombableType(tile));
        }
예제 #18
0
 public override void MeleeEffects(Player player, Rectangle hitbox)
 {
     if (Main.rand.NextBool(10))
     {
         int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, DustID.Electric);
     }
     if (player.altFunctionUse == 2 || (player.altFunctionUse != 2 && Main.mouseRight))
     {
         int range    = 32;
         int minTileX = (int)(player.position.X / 16f - (float)range);
         int maxTileX = (int)(player.position.X / 16f + (float)range);
         int minTileY = (int)(player.position.Y / 16f - (float)range);
         int maxTileY = (int)(player.position.Y / 16f + (float)range);
         if (minTileX < 0)
         {
             minTileX = 0;
         }
         if (maxTileX > Main.maxTilesX)
         {
             maxTileX = Main.maxTilesX;
         }
         if (minTileY < 0)
         {
             minTileY = 0;
         }
         if (maxTileY > Main.maxTilesY)
         {
             maxTileY = Main.maxTilesY;
         }
         for (int i = minTileX; i < maxTileX; ++i)
         {
             for (int j = minTileY; j < maxTileY; ++j)
             {
                 if (Main.tileDungeon[(int)Main.tile[i, j].type] || Main.tile[i, j].type == 88 || Main.tile[i, j].type == 21 || Main.tile[i, j].type == 26 || Main.tile[i, j].type == 107 || Main.tile[i, j].type == 108 || Main.tile[i, j].type == 111 || Main.tile[i, j].type == 226 || Main.tile[i, j].type == 237 || Main.tile[i, j].type == 221 || Main.tile[i, j].type == 222 || Main.tile[i, j].type == 223 || Main.tile[i, j].type == 211 || Main.tile[i, j].type == 404)
                 {
                     continue;
                 }
                 if (!Main.hardMode && Main.tile[i, j].type == 58)
                 {
                     continue;
                 }
                 if (!TileLoader.CanExplode(i, j))
                 {
                     continue;
                 }
                 if (Main.tile[i, j].type == null)
                 {
                     continue;
                 }
                 if (!Main.tile[i, j].active())
                 {
                     continue;
                 }
                 if (hitbox.Intersects(new Rectangle(i * 16, j * 16, 16, 16)))
                 {
                     WorldGen.KillTile(i, j, false, false, false);
                 }
             }
         }
     }
 }