public override bool PreAI(Projectile projectile)
 {
     if (!projectile.tileCollide && projectile.aiStyle != 26 && !projectile.minion && projectile.damage > 0 && projectile.friendly)
     {
         int x = (int)MathHelper.Clamp(projectile.Center.X / 16, 0, Main.maxTilesX - 2);
         int y = (int)MathHelper.Clamp(projectile.Center.Y / 16, 0, Main.maxTilesY - 2);
         if (Main.tile[x, y] != null && Main.tile[x, y].active())
         {
             if (Main.tile[x, y].type == (ushort)mod.TileType("BlueHatch"))
             {
                 TileLoader.HitWire(x, y, mod.TileType("BlueHatch"));
             }
             if (Main.tile[x, y].type == (ushort)mod.TileType("BlueHatchVertical"))
             {
                 TileLoader.HitWire(x, y, mod.TileType("BlueHatchVertical"));
             }
         }
     }
     if (!init)
     {
         projSpeed = projectile.velocity.Length();
         init      = true;
     }
     return(base.PreAI(projectile));
 }
예제 #2
0
        public override void AI()
        {
            Projectile P = projectile;

            float vacSpeedIncr = 0.05f;

            P.ai[0] += 1f / (1 + P.extraUpdates);
            if (P.ai[0] < maxDist)
            {
                if (P.numUpdates == 0)
                {
                    speed *= 0.99f;
                }
                scale += 0.04f * speed / (1 + P.extraUpdates);
            }
            else
            {
                if (P.numUpdates == 0)
                {
                    speed *= 1.01f;
                }
                scale       -= 0.04f * speed / (1 + P.extraUpdates);
                vacSpeedIncr = 0.5f;
            }

            if (P.numUpdates == 0)
            {
                itemVacSpeed = Math.Min(itemVacSpeed + vacSpeedIncr, 20f);
                npcVacSpeed  = Math.Min(npcVacSpeed + vacSpeedIncr, 40f);

                for (int i = 0; i < Main.item.Length; i++)
                {
                    if (!Main.item[i].active)
                    {
                        continue;
                    }

                    Item I = Main.item[i];
                    if (P.Hitbox.Intersects(I.Hitbox))
                    {
                        Vector2 center   = new Vector2(P.Center.X, P.Center.Y - ((float)I.height / 2f));
                        Vector2 velocity = Vector2.Normalize(center - I.Center) * Math.Min(itemVacSpeed, Vector2.Distance(center, I.Center));
                        if (Vector2.Distance(center, I.Center) > 1f)
                        {
                            I.position += velocity;
                            I.velocity *= 0f;
                        }
                    }
                }

                for (int i = 0; i < Main.npc.Length; i++)
                {
                    if (Main.npc[i].CanBeChasedBy(P, false) && Main.npc[i].knockBackResist != 0f)
                    {
                        NPC N = Main.npc[i];
                        if (P.Hitbox.Intersects(N.Hitbox))
                        {
                            Vector2 center   = new Vector2(P.Center.X, P.Center.Y - ((float)N.height / 2f));
                            Vector2 velocity = Vector2.Normalize(center - N.Center) * Math.Min(npcVacSpeed * N.knockBackResist, Vector2.Distance(center, N.Center));
                            if (Vector2.Distance(center, N.Center) > 1f)
                            {
                                N.position += velocity;
                                N.velocity *= 0f;
                            }
                        }
                    }
                }
            }

            /*int num = (int)(100f*P.scale);
             * for(int i = 0; i < num; i++)
             * {
             *      float angle = (float)((Math.PI*2)/num)*i;
             *      Vector2 position = P.Center - new Vector2(20,20);
             *      position.X += (float)Math.Cos(angle)*((float)P.width/2f);
             *      position.Y += (float)Math.Sin(angle)*((float)P.height/2f);
             *      int num20 = Dust.NewDust(position, 40, 40, 229, 0f, 0f, 100, default(Color), 1f);
             *      Dust dust = Main.dust[num20];
             *      dust.velocity += Vector2.Normalize(P.Center - dust.position) * 10f;// * P.scale;
             *      dust.noGravity = true;
             * }*/
            int num = 20;

            for (int i = 0; i < num; i++)
            {
                float angle = (float)((Math.PI * 2) / num) * i;
                angle += ((float)Math.PI / 20f) * P.ai[0];
                Vector2 position = P.Center;
                position.X += (float)Math.Cos(angle) * ((float)P.width / 2f);
                position.Y += (float)Math.Sin(angle) * ((float)P.height / 2f);
                int  num20 = Dust.NewDust(position, 1, 1, 229, 0f, 0f, 100, default(Color), MathHelper.Clamp(P.scale, 1f, 3f));
                Dust dust  = Main.dust[num20];
                dust.position  = position;
                dust.velocity  = Vector2.Normalize(P.Center - dust.position) * 10f;
                dust.noGravity = true;
            }

            if (scale > 0f)
            {
                P.timeLeft = 2;
            }

            P.scale      = scale;
            P.position.X = P.position.X + (float)(P.width / 2);
            P.position.Y = P.position.Y + (float)(P.height / 2);
            P.width      = (int)((float)width * P.scale);
            P.height     = (int)((float)height * P.scale);
            P.position.X = P.position.X - (float)(P.width / 2);
            P.position.Y = P.position.Y - (float)(P.height / 2);

            if ((int)P.ai[0] == maxDist && P.numUpdates == 0)
            {
                Rectangle tileRect = new Rectangle((int)(P.position.X / 16), (int)(P.position.Y / 16), (P.width / 16), (P.height / 16));
                for (int x = tileRect.X; x < tileRect.X + tileRect.Width; x++)
                {
                    for (int y = tileRect.Y; y < tileRect.Y + tileRect.Height; y++)
                    {
                        if (Main.tile[x, y] != null && Main.tile[x, y].active())
                        {
                            if (Main.tile[x, y].type == (ushort)mod.TileType("YellowHatch"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("YellowHatch"));
                            }
                            if (Main.tile[x, y].type == (ushort)mod.TileType("YellowHatchVertical"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("YellowHatchVertical"));
                            }
                            if (Main.tile[x, y].type == (ushort)mod.TileType("BlueHatch"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("BlueHatch"));
                            }
                            if (Main.tile[x, y].type == (ushort)mod.TileType("BlueHatchVertical"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("BlueHatchVertical"));
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        public override void AI()
        {
            float speed = 2f;

            colory = Color.Yellow;
            projectile.timeLeft = 60;
            projectile.frameCounter++;

            if (projectile.frameCounter < maxDistance)
            {
                scaleSize += speed;

                int num = (int)(50f * projectile.scale);
                for (int i = 0; i < num; i++)
                {
                    float   angle    = (float)((Math.PI * 2) / num) * i;
                    Vector2 position = projectile.Center - new Vector2(10, 10);
                    position.X += (float)Math.Cos(angle) * ((float)projectile.width / 2f);
                    position.Y += (float)Math.Sin(angle) * ((float)projectile.height / 2f);
                    int  num20 = Dust.NewDust(position, 20, 20, 57, 0f, 0f, 100, default(Color), 3f);
                    Dust dust  = Main.dust[num20];
                    dust.velocity += Vector2.Normalize(projectile.Center - dust.position) * 5f * projectile.scale;
                    dust.noGravity = true;
                }
            }
            else
            {
                scaleSize        -= speed;
                colory            = Color.Black;
                projectile.damage = 0;
                for (int i = 0; i < Main.item.Length; i++)
                {
                    if (!Main.item[i].active)
                    {
                        continue;
                    }

                    Item I = Main.item[i];
                    if (projectile.Hitbox.Intersects(I.Hitbox))
                    {
                        Vector2 center   = new Vector2(projectile.Center.X, projectile.Center.Y - ((float)I.height / 2f));
                        Vector2 velocity = Vector2.Normalize(center - I.Center) * Math.Min(20f, Vector2.Distance(center, I.Center));
                        if (Vector2.Distance(center, I.Center) > 1f)
                        {
                            I.position += velocity;
                            I.velocity *= 0f;
                        }
                    }
                }
            }
            if (projectile.frameCounter >= (maxDistance * 2))
            {
                scaleSize = 1f;
                colory    = Color.Gold;
                projectile.frameCounter = 0;
                projectile.Kill();
            }

            projectile.scale      = scaleSize * 0.02f;
            projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
            projectile.width      = (int)((float)width * projectile.scale);
            projectile.height     = (int)((float)height * projectile.scale);
            projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
            projectile.netUpdate  = true;

            if (projectile.frameCounter == maxDistance)
            {
                Rectangle tileRect = new Rectangle((int)(projectile.position.X / 16), (int)(projectile.position.Y / 16), (projectile.width / 16), (projectile.height / 16));
                for (int x = tileRect.X; x < tileRect.X + tileRect.Width; x++)
                {
                    for (int y = tileRect.Y; y < tileRect.Y + tileRect.Height; y++)
                    {
                        if (Main.tile[x, y] != null && Main.tile[x, y].active())
                        {
                            if (Main.tile[x, y].type == (ushort)mod.TileType("YellowHatch"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("YellowHatch"));
                            }
                            if (Main.tile[x, y].type == (ushort)mod.TileType("YellowHatchVertical"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("YellowHatchVertical"));
                            }
                            if (Main.tile[x, y].type == (ushort)mod.TileType("BlueHatch"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("BlueHatch"));
                            }
                            if (Main.tile[x, y].type == (ushort)mod.TileType("BlueHatchVertical"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("BlueHatchVertical"));
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        public override void AI()
        {
            Projectile P = projectile;

            P.ai[0]++;
            if (P.ai[0] > maxDist / 4)
            {
                speed *= 0.955f;
            }
            if (P.ai[0] > maxDist)
            {
                if (vacAlpha < 1f)
                {
                    float     vacScale = 6f * (1f - vacAlpha);
                    int       vacW     = (int)((float)width * vacScale);
                    int       vacH     = (int)((float)height * vacScale);
                    Rectangle vacRect  = new Rectangle((int)(P.Center.X - vacW / 2), (int)(P.Center.Y - vacH / 2), vacW, vacH);
                    for (int i = 0; i < Main.item.Length; i++)
                    {
                        if (!Main.item[i].active)
                        {
                            continue;
                        }

                        Item I = Main.item[i];
                        if (vacRect.Intersects(I.Hitbox))
                        {
                            Vector2 center   = new Vector2(P.Center.X, P.Center.Y - ((float)I.height / 2f));
                            Vector2 velocity = Vector2.Normalize(center - I.Center) * Math.Min(20f, Vector2.Distance(center, I.Center));
                            if (Vector2.Distance(center, I.Center) > 1f)
                            {
                                I.position += velocity;
                                I.velocity *= 0f;
                            }
                        }
                    }

                    vacAlpha += 1f / maxDist;
                }
                else
                {
                    P.damage = 0;
                }
            }
            else
            {
                float dScale = Math.Min(10f * (1f - P.ai[0] / maxDist), 4f);
                int   num    = (int)(100f * dScale);
                for (int i = 0; i < num; i++)
                {
                    int dType = Utils.SelectRandom <int>(Main.rand, new int[]
                    {
                        6,
                        259,
                        158
                    });

                    float   angle    = (float)((Math.PI * 2) / num) * i;
                    Vector2 position = P.Center - new Vector2(20, 20);
                    position.X += (float)Math.Cos(angle) * ((float)P.width / 2f - 16f * P.scale);
                    position.Y += (float)Math.Sin(angle) * ((float)P.height / 2f - 16f * P.scale);
                    int  num20 = Dust.NewDust(position, 40, 40, dType, 0f, 0f, 100, default(Color), 1f);
                    Dust dust  = Main.dust[num20];
                    dust.velocity += Vector2.Normalize(P.Center - dust.position) * 2f;                    // * 5f * P.scale;
                    dust.alpha     = 200;
                    dust.scale    += Main.rand.NextFloat();
                    dust.noGravity = true;
                }
            }
            scale += 0.04f * speed;

            P.scale       = scale;
            P.position.X += (float)(P.width / 2);
            P.position.Y += (float)(P.height / 2);
            P.width       = (int)((float)width * P.scale);
            P.height      = (int)((float)height * P.scale);
            P.position.X -= (float)(P.width / 2);
            P.position.Y -= (float)(P.height / 2);

            if (P.alpha < 255)
            {
                P.alpha++;
                P.timeLeft = 2;
            }

            if (P.ai[0] == maxDist)
            {
                Rectangle tileRect = new Rectangle((int)(P.position.X / 16), (int)(P.position.Y / 16), (P.width / 16), (P.height / 16));
                for (int x = tileRect.X; x < tileRect.X + tileRect.Width; x++)
                {
                    for (int y = tileRect.Y; y < tileRect.Y + tileRect.Height; y++)
                    {
                        if (Main.tile[x, y] != null && Main.tile[x, y].active())
                        {
                            if (Main.tile[x, y].type == (ushort)mod.TileType("YellowHatch"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("YellowHatch"));
                            }
                            if (Main.tile[x, y].type == (ushort)mod.TileType("YellowHatchVertical"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("YellowHatchVertical"));
                            }
                            if (Main.tile[x, y].type == (ushort)mod.TileType("BlueHatch"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("BlueHatch"));
                            }
                            if (Main.tile[x, y].type == (ushort)mod.TileType("BlueHatchVertical"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("BlueHatchVertical"));
                            }
                        }
                    }
                }
            }
        }
        public override void Kill(Projectile projectile, int timeLeft)
        {
            int tilex  = (int)(projectile.position.X / 16) - 1;
            int tiley  = (int)(projectile.position.Y / 16) - 1;
            int tilex2 = (int)((projectile.position.X + projectile.width) / 16) + 1;
            int tiley2 = (int)((projectile.position.Y + projectile.height) / 16) + 1;

            if (tilex < 0)
            {
                tilex = 0;
            }
            if (tilex2 > Main.maxTilesX)
            {
                tilex2 = Main.maxTilesX;
            }
            if (tiley < 0)
            {
                tiley = 0;
            }
            if (tiley2 > Main.maxTilesY)
            {
                tiley2 = Main.maxTilesY;
            }
            for (int x = tilex; x < tilex2; x++)
            {
                for (int y = tiley; y < tiley2; y++)
                {
                    if (Main.tile[x, y] != null && Main.tile[x, y].active())
                    {
                        if (Main.tile[x, y].type == (ushort)mod.TileType("BlueHatch"))
                        {
                            TileLoader.HitWire(x, y, mod.TileType("BlueHatch"));
                        }
                        if (Main.tile[x, y].type == (ushort)mod.TileType("BlueHatchVertical"))
                        {
                            TileLoader.HitWire(x, y, mod.TileType("BlueHatchVertical"));
                        }
                        if (projectile.Name.Contains("Missile"))
                        {
                            if (Main.tile[x, y].type == (ushort)mod.TileType("RedHatch"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("RedHatch"));
                            }
                            if (Main.tile[x, y].type == (ushort)mod.TileType("RedHatchVertical"))
                            {
                                TileLoader.HitWire(x, y, mod.TileType("RedHatchVertical"));
                            }
                            if (projectile.Name.Contains("Super") || projectile.Name.Contains("Nebula") || projectile.Name.Contains("Stardust"))
                            {
                                if (Main.tile[x, y].type == (ushort)mod.TileType("GreenHatch"))
                                {
                                    TileLoader.HitWire(x, y, mod.TileType("GreenHatch"));
                                }
                                if (Main.tile[x, y].type == (ushort)mod.TileType("GreenHatchVertical"))
                                {
                                    TileLoader.HitWire(x, y, mod.TileType("GreenHatchVertical"));
                                }
                            }
                        }
                    }
                }
            }
        }