Kill() public method

public Kill ( ) : void
return void
Example #1
0
        public static void SpearAI(int index, float protractSpeed = 1.5f, float retractSpeed = 1.4f, ExtraAction action = null, ExtraAction initialize = null)
        {
            Terraria.Projectile projectile = Main.projectile[index];
            if (initialize != null && projectile.localAI[1] == 0f)
            {
                projectile.localAI[1] = 1f;
                initialize();
            }
            Vector2 vector = Main.player[projectile.owner].RotatedRelativePoint(Main.player[projectile.owner].MountedCenter, true);

            projectile.direction = Main.player[projectile.owner].direction;
            Main.player[projectile.owner].heldProj = projectile.whoAmI;
            Main.player[projectile.owner].itemTime = Main.player[projectile.owner].itemAnimation;
            projectile.position.X = vector.X - (float)(projectile.width / 2);
            projectile.position.Y = vector.Y - (float)(projectile.height / 2);
            if (!Main.player[projectile.owner].frozen)
            {
                if (projectile.ai[0] == 0f)
                {
                    projectile.ai[0]     = 3f;
                    projectile.netUpdate = true;
                }
                if (Main.player[projectile.owner].itemAnimation < Main.player[projectile.owner].itemAnimationMax / 3)
                {
                    projectile.ai[0] -= retractSpeed;
                }
                else
                {
                    projectile.ai[0] += protractSpeed;
                }
            }
            projectile.position += projectile.velocity * projectile.ai[0];
            if (Main.player[projectile.owner].itemAnimation == 0)
            {
                projectile.Kill();
            }
            projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 2.355f;
            if (projectile.spriteDirection == -1)
            {
                projectile.rotation -= 1.57f;
            }
            if (action != null)
            {
                action();
            }
        }
Example #2
0
        public static void BoomerangAI(int index, float retractTime = 30f, float speed = 9f, float speedAcceleration = 0.4f, ExtraAction action = null, ExtraAction initialize = null)
        {
            Terraria.Projectile projectile = Main.projectile[index];
            if (initialize != null && projectile.localAI[1] == 0f)
            {
                projectile.localAI[1] = 1f;
                initialize();
            }
            if (projectile.soundDelay == 0)
            {
                projectile.soundDelay = 8;
                Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 7);
            }

            if (projectile.ai[0] == 0f)
            {
                projectile.ai[1] += 1f;
                if (projectile.ai[1] >= retractTime)
                {
                    projectile.ai[0]     = 1f;
                    projectile.ai[1]     = 0f;
                    projectile.netUpdate = true;
                }
            }
            else
            {
                projectile.tileCollide = false;
                Vector2 vector = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
                float   num    = Main.player[projectile.owner].position.X + (float)(Main.player[projectile.owner].width / 2) - vector.X;
                float   num2   = Main.player[projectile.owner].position.Y + (float)(Main.player[projectile.owner].height / 2) - vector.Y;
                float   num3   = (float)Math.Sqrt((double)(num * num + num2 * num2));
                if (num3 > 3000f)
                {
                    projectile.Kill();
                }

                num3  = speed / num3;
                num  *= num3;
                num2 *= num3;

                if (projectile.velocity.X < num)
                {
                    projectile.velocity.X = projectile.velocity.X + speedAcceleration;
                    if (projectile.velocity.X < 0f && num > 0f)
                    {
                        projectile.velocity.X = projectile.velocity.X + speedAcceleration;
                    }
                }
                else if (projectile.velocity.X > num)
                {
                    projectile.velocity.X = projectile.velocity.X - speedAcceleration;
                    if (projectile.velocity.X > 0f && num < 0f)
                    {
                        projectile.velocity.X = projectile.velocity.X - speedAcceleration;
                    }
                }

                if (projectile.velocity.Y < num2)
                {
                    projectile.velocity.Y = projectile.velocity.Y + speedAcceleration;
                    if (projectile.velocity.Y < 0f && num2 > 0f)
                    {
                        projectile.velocity.Y = projectile.velocity.Y + speedAcceleration;
                    }
                }
                else if (projectile.velocity.Y > num2)
                {
                    projectile.velocity.Y = projectile.velocity.Y - speedAcceleration;
                    if (projectile.velocity.Y > 0f && num2 < 0f)
                    {
                        projectile.velocity.Y = projectile.velocity.Y - speedAcceleration;
                    }
                }

                if (Main.myPlayer == projectile.owner)
                {
                    Rectangle rectangle = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height);
                    Rectangle value     = new Rectangle((int)Main.player[projectile.owner].position.X, (int)Main.player[projectile.owner].position.Y, Main.player[projectile.owner].width, Main.player[projectile.owner].height);
                    if (rectangle.Intersects(value))
                    {
                        projectile.Kill();
                    }
                }
            }
            projectile.rotation += 0.4f * (float)projectile.direction;
            if (action != null)
            {
                action();
            }
        }
Example #3
0
        public static void FlailAI(int index, float initialRange = 160f, float weaponOutRange = 300f, float retractRange = 100f, ExtraAction action = null, ExtraAction initialize = null)
        {
            Terraria.Projectile projectile = Main.projectile[index];
            if (initialize != null && projectile.localAI[1] == 0f)
            {
                projectile.localAI[1] = 1f;
                initialize();
            }
            if (Main.player[projectile.owner].dead)
            {
                projectile.Kill();
                return;
            }
            Main.player[projectile.owner].itemAnimation = 10;
            Main.player[projectile.owner].itemTime      = 10;
            if (projectile.position.X + (float)(projectile.width / 2) > Main.player[projectile.owner].position.X + (float)(Main.player[projectile.owner].width / 2))
            {
                Main.player[projectile.owner].ChangeDir(1);
                projectile.direction = 1;
            }
            else
            {
                Main.player[projectile.owner].ChangeDir(-1);
                projectile.direction = -1;
            }
            Vector2 mountedCenter = Main.player[projectile.owner].MountedCenter;
            Vector2 vector        = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
            float   num           = mountedCenter.X - vector.X;
            float   num2          = mountedCenter.Y - vector.Y;
            float   num3          = (float)Math.Sqrt((double)(num * num + num2 * num2));

            if (projectile.ai[0] == 0f)
            {
                projectile.tileCollide = true;
                if (num3 > initialRange)
                {
                    projectile.ai[0]     = 1f;
                    projectile.netUpdate = true;
                }
                else if (!Main.player[projectile.owner].channel)
                {
                    if (projectile.velocity.Y < 0f)
                    {
                        projectile.velocity.Y = projectile.velocity.Y * 0.9f;
                    }
                    projectile.velocity.Y = projectile.velocity.Y + 1f;
                    projectile.velocity.X = projectile.velocity.X * 0.9f;
                }
            }
            else if (projectile.ai[0] == 1f)
            {
                float num4 = 14f / Main.player[projectile.owner].meleeSpeed;
                float num5 = 0.9f / Main.player[projectile.owner].meleeSpeed;
                Math.Abs(num);
                Math.Abs(num2);
                if (projectile.ai[1] == 1f)
                {
                    projectile.tileCollide = false;
                }
                if (!Main.player[projectile.owner].channel || num3 > weaponOutRange || !projectile.tileCollide)
                {
                    projectile.ai[1] = 1f;
                    if (projectile.tileCollide)
                    {
                        projectile.netUpdate = true;
                    }
                    projectile.tileCollide = false;
                    if (num3 < 20f)
                    {
                        projectile.Kill();
                    }
                }
                if (!projectile.tileCollide)
                {
                    num5 *= 2f;
                }
                int num6 = (int)retractRange;
                if (num3 > (float)num6 || !projectile.tileCollide)
                {
                    num3  = num4 / num3;
                    num  *= num3;
                    num2 *= num3;
                    new Vector2(projectile.velocity.X, projectile.velocity.Y);
                    float num7 = num - projectile.velocity.X;
                    float num8 = num2 - projectile.velocity.Y;
                    float num9 = (float)Math.Sqrt((double)(num7 * num7 + num8 * num8));
                    num9  = num5 / num9;
                    num7 *= num9;
                    num8 *= num9;
                    projectile.velocity.X = projectile.velocity.X * 0.98f;
                    projectile.velocity.Y = projectile.velocity.Y * 0.98f;
                    projectile.velocity.X = projectile.velocity.X + num7;
                    projectile.velocity.Y = projectile.velocity.Y + num8;
                }
                else
                {
                    if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < 6f)
                    {
                        projectile.velocity.X = projectile.velocity.X * 0.96f;
                        projectile.velocity.Y = projectile.velocity.Y + 0.2f;
                    }
                    if (Main.player[projectile.owner].velocity.X == 0f)
                    {
                        projectile.velocity.X = projectile.velocity.X * 0.96f;
                    }
                }
            }
            if (projectile.velocity.X < 0f)
            {
                projectile.rotation -= (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f;
            }
            else
            {
                projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.01f;
            }
            if (action != null)
            {
                action();
            }
        }
        public static void ProjectileAiStyles(Projectile p, int aiStyle)
        {
            if (p.aiStyle == 125)
            {
                if (p.type != 656)
                {
                    if (p.type == 653)
                    {
                        for (int num92 = 0; num92 < 5; num92++)
                        {
                            float num93 = p.velocity.X / 3f * (float)num92;
                            float num94 = p.velocity.Y / 3f * (float)num92;
                            int num95 = 4;
                            int num96 = Dust.NewDust(new Vector2(p.position.X + (float)num95, p.position.Y + (float)num95), p.width - num95 * 2, p.height - num95 * 2, 6, 0f, 0f, 100, default(Color), 1.2f);
                            Main.dust[num96].noGravity = true;
                            Main.dust[num96].velocity *= 0.1f;
                            Main.dust[num96].velocity += p.velocity * 0.1f;
                            Dust expr_47FA_cp_0 = Main.dust[num96];
                            expr_47FA_cp_0.position.X = expr_47FA_cp_0.position.X - num93;
                            Dust expr_4815_cp_0 = Main.dust[num96];
                            expr_4815_cp_0.position.Y = expr_4815_cp_0.position.Y - num94;
                        }
                        if (Main.rand.Next(5) == 0)
                        {
                            int num97 = 4;
                            int num98 = Dust.NewDust(new Vector2(p.position.X + (float)num97, p.position.Y + (float)num97), p.width - num97 * 2, p.height - num97 * 2, 6, 0f, 0f, 100, default(Color), 0.6f);
                            Main.dust[num98].velocity *= 0.25f;
                            Main.dust[num98].velocity += p.velocity * 0.5f;
                        }
                    }
                    if (p.ai[0] < 45f && p.ai[1] == 0)
                    {
                        p.ai[0] += 1f;
                    }
                    else if (p.ai[0] == 45f && p.ai[1] == 0)
                    {
                        p.Kill();
                    }
                    else if (p.ai[1] == 1f)
                    {
                        p.velocity *= 1.4f;
                        p.ai[1]++;
                    }
                    else if (p.ai[1] >= 1f && p.ai[1] < 40f)
                    {
                        p.ai[1]++;
                    }
                    if (p.ai[1] >= 10f)
                    {
                        p.Kill();
                    }
                }
                else
                {
                    for (int num92 = 0; num92 < 5; num92++)
                    {
                        float num93 = p.velocity.X / 3f * (float)num92;
                        float num94 = p.velocity.Y / 3f * (float)num92;
                        int num95 = 4;
                        int num96 = Dust.NewDust(new Vector2(p.position.X + (float)num95, p.position.Y + (float)num95), p.width - num95 * 2, p.height - num95 * 2, 180, 0f, 0f, 100, default(Color), 1.2f);
                        Main.dust[num96].noGravity = true;
                        Main.dust[num96].velocity *= 0.1f;
                        Main.dust[num96].velocity += p.velocity * 0.1f;
                        Dust expr_47FA_cp_0 = Main.dust[num96];
                        expr_47FA_cp_0.position.X = expr_47FA_cp_0.position.X - num93;
                        Dust expr_4815_cp_0 = Main.dust[num96];
                        expr_4815_cp_0.position.Y = expr_4815_cp_0.position.Y - num94;
                    }
                    if (Main.rand.Next(5) == 0)
                    {
                        int num97 = 4;
                        int num98 = Dust.NewDust(new Vector2(p.position.X + (float)num97, p.position.Y + (float)num97), p.width - num97 * 2, p.height - num97 * 2, 180, 0f, 0f, 100, default(Color), 0.6f);
                        Main.dust[num98].velocity *= 0.25f;
                        Main.dust[num98].velocity += p.velocity * 0.5f;
                    }
                    p.ai[0]++;
                    if (p.ai[0] < 90)
                    {
                        float sp = 8f;
                        Vector2 pos = Main.player[Main.myPlayer].Center - p.Center;
                        float mag = (float)Math.Sqrt(pos.X * pos.X + pos.Y * pos.Y);
                        if (mag > sp)
                        {
                            pos *= mag / sp;
                        }
                        p.velocity = pos;
                    }
                    else
                    {
                        p.velocity *= 1.02f;
                    }
                }
            }
            else if (p.aiStyle == 126)
            {
                if (p.type == 659)
                {
                    p.ai[0]++;
                    if (p.ai[0] < 30f && p.ai[1] == 0f)
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            int dust = Dust.NewDust(p.position, p.width, p.height, 135, p.velocity.X, p.velocity.Y);
                            Main.dust[dust].noGravity = true;
                        }
                    }
                    else
                    {
                        if (p.ai[2] == 10f && p.ai[1] == 0f)
                        {
                            p.Kill();
                        }
                        if (p.ai[1] == 1f)
                        {
                            p.position.X = p.position.X + (float)(p.width / 2);
                            p.position.Y = p.position.Y + (float)(p.height / 2);
                            p.width = 1024;
                            p.height = 128;
                            p.position.X = p.position.X - (float)(p.width / 2);
                            p.position.Y = p.position.Y - (float)(p.height / 2);
                            p.damage = 45;
                            p.knockBack = 16f;
                            p.ai[2] = 10f;
                        }
                        else
                        {
                            p.Kill();
                        }
                    }
                }
                else if (p.type == 660)
                {
                    p.rotation += MathHelper.ToRadians(54f);
                    for (int i = 0; i < 5; i++)
                    {
                        int dust = Dust.NewDust(p.position, p.width, p.height, 41, p.velocity.X, p.velocity.Y);
                        Main.dust[dust].noGravity = true;
                    }
                }
            }
            else if (p.aiStyle == 127)
            {
                p.ai[0]++;
                if (p.ai[0] > 15)
                {
                    if (p.type != 669)
                    {
                        p.velocity *= 0.96f;
                    }
                    else
                    {
                        p.velocity *= 0.975f;
                    }
                }
                p.spriteDirection = p.direction;
                if (p.direction < 0)
                {
                    p.rotation = (float)Math.Atan2((double)(-(double)p.velocity.Y), (double)(-(double)p.velocity.X));
                }
                else
                {
                    p.rotation = (float)Math.Atan2((double)p.velocity.Y, (double)p.velocity.X);
                }
                p.frameCounter++;
                if (p.frameCounter > 4)
                {
                    p.frame++;
                    p.frameCounter = 0;
                }
                if (p.frame > 3)
                {
                    p.frame = 0;
                    return;
                }
            }
            else if (p.aiStyle == 128)
            {
                if (p.type == 678)
                {
                    p.ai[0]++;
                    if (p.ai[0] == 1)
                    {
                        int d = Dust.NewDust(p.position, 14, 14, 197, 0f, 0f, 0);
                        Main.dust[d].velocity = new Vector2(0f, 0f);
                        Main.dust[d].noGravity = true;
                        p.ai[0] = -2f;
                    }
                }
                else if (p.type == 680)
                {
                    p.rotation = (float)Math.Atan2(p.velocity.Y, p.velocity.X);
                    for (int i = 0; i < 2; i++)
                    {
                        int d = Dust.NewDust(p.position, p.width, p.height, 271, 0f, 0f, 0);
                        Main.dust[d].noGravity = true;
                        Main.dust[d].velocity = new Vector2(0f, 0f);
                    }
                }
                else if (p.type == 681)
                {
                    p.ai[0]++;
                    if (p.ai[0] < 320)
                    {
                        float speed = (float)((2 * Math.PI) / 60);
                        float radius = 50;
                        p.circularAngle += speed;
                        p.position.X = (float)Math.Cos(p.circularAngle) * radius + Main.npc[(int)p.ai[1]].Center.X;
                        p.position.Y = (float)Math.Sin(p.circularAngle) * radius + Main.npc[(int)p.ai[1]].Center.Y;
                        for (int i = 0; i < 4; i++)
                        {
                            int d = Dust.NewDust(p.position, 12, 12, 252, 0f, 0f);
                            Main.dust[d].noGravity = true;
                        }
                        if (Main.npc[(int)p.ai[1]].life <= 0)
                        {
                            p.Kill();
                        }
                    }
                    else
                    {
                        p.Kill();
                    }
                }
                else if (p.type >= 682 && p.type <= 684 || p.type == 745)
                {
                    p.rotation = (float)Math.Atan2(p.velocity.Y, p.velocity.X);
                }
                else if (p.type == 685)
                {
                    p.ai[5]++;
                    if (p.ai[5] < 900)
                    {
                        p.Center = new Vector2(Main.npc[(int)p.ai[1]].Center.X, Main.npc[(int)p.ai[1]].Center.Y);
                        Vector2 thing = p.Center - new Vector2(Main.player[Main.npc[(int)p.ai[1]].target].Center.X, Main.player[Main.npc[(int)p.ai[1]].target].Center.Y);
                        float toBeRotation = (float)Math.Atan2(thing.Y, thing.X);
                        p.rotation = Ulterraria.CurveAngle(p.rotation, toBeRotation, 0.06f);
                        p.ai[0]++;
                        if (p.ai[0] == 10)
                        {
                            Vector2 newVelocity = new Vector2((float)Math.Cos(p.rotation), (float)Math.Sin(p.rotation));
                            newVelocity *= 9f;
                            int proj = Projectile.NewProjectile(p.Center.X, p.Center.Y, -newVelocity.X, -newVelocity.Y, 14, 40, 1f, Main.myPlayer);
                            Main.projectile[proj].hostile = true;
                            Main.projectile[proj].friendly = false;
                            p.ai[0] = 0;
                        }
                        if (Main.npc[(int)p.ai[1]].life <= 0 || !Main.npc[(int)p.ai[1]].active)
                        {
                            p.Kill();
                        }
                    }
                    else
                    {
                        if (p.ai[5] == 900)
                        {
                            p.ai[4] = Main.rand.Next(2);
                        }
                        else
                        {
                            p.velocity.Y *= 1.008f; ;
                            p.tileCollide = true;
                            p.rotation += (p.ai[4] == 0 ? MathHelper.ToDegrees(0.5f) : MathHelper.ToDegrees(-0.5f));
                        }
                    }
                }
            }
            else if (p.aiStyle == 129)
            {
                for (int q = 0; q < Main.projectile.Length; q++)
                {
                    if (Main.projectile[q].type == 690 && q != p.whoAmI)
                    {
                        Main.projectile[q].Kill();
                    }
                }
                int s = p.type == 686 ? 120 : p.type == 690 ? 45 : 90;
                if (p.type == 844)
                {
                    s = 20;
                }
                float speed = (float)((2 * Math.PI) / s);
                float radius = 40;
                if (p.type == 844)
                {
                    radius = 140;
                }
                p.circularAngle += speed;
                p.position.X = (float)Math.Cos(p.circularAngle) * radius + Main.player[Main.myPlayer].Center.X - 10;
                p.position.Y = (float)Math.Sin(p.circularAngle) * radius + Main.player[Main.myPlayer].Center.Y - 10;
                for (int i = 0; i < 8; i++)
                {
                    int d = 0;
                    if (p.type == 686)
                        d = Dust.NewDust(p.position, 16, 16, 6, 0f, 0f);
                    else if (p.type == 687)
                        d = Dust.NewDust(p.position, 16, 16, 135, 0f, 0f);
                    else if (p.type == 690)
                        d = Dust.NewDust(p.position, 16, 16, 227, 0f, 0f);
                    else if (p.type == 844)
                        d = Dust.NewDust(p.position, 16, 16, 143, 0f, 0f);
                    Main.dust[d].noGravity = true;
                }
            }
            else if (p.aiStyle == 130)
            {
                if (p.ai[0] == 0)
                {
                    int waterX = 0, waterY = 0;
                    int target = 400;
                    bool electrocute = false;
                    p.dest = new Vector2((float)Main.mouseX + Main.screenPosition.X, (float)Main.mouseY + Main.screenPosition.Y);
                    int mainA = (int)(Vector2.Distance(Main.player[Main.myPlayer].Center, p.dest) / 34);
                    int secA = mainA - 11;
                    if (mainA < 4) mainA = 4;
                    if (secA < 4) secA = 4;
                    p.mainArc = new Vector2[mainA];
                    p.secondaryArc = new Vector2[secA][];
                    for (int i = 0; i < p.secondaryArc.Length; i++)
                    {
                        p.secondaryArc[i] = new Vector2[8];
                    }
                    p.velocity = Vector2.Zero;
                    Vector2 v = p.dest;
                    float radius = 220f;
                    float close = radius;
                    float lastClose = close;
                    int lastTarget = target;
                    #region Corners
                    for (int i = 0; i < Main.npc.Length; i++)
                    {
                        if (Main.npc[i].friendly == false && Vector2.Distance(p.dest, Main.npc[i].Center) < radius)
                        {
                            lastClose = close;
                            lastTarget = target;
                            Vector2 v1 = new Vector2(Main.npc[i].position.X, Main.npc[i].position.Y);
                            float len = (v1 - v).Length();
                            if (len <= radius && len < close)
                            {
                                close = len;
                                target = i;
                            }
                            v1.Y += (float)Main.npc[i].height;
                            len = (v1 - v).Length();
                            if (len <= radius && len < close)
                            {
                                close = len;
                                target = i;
                            }
                            v.X += (float)Main.npc[i].width;
                            len = (v1 - v).Length();
                            if (len <= radius && len < close)
                            {
                                close = len;
                                target = i;
                            }
                            v.Y -= (float)Main.npc[i].height;
                            len = (v1 - v).Length();
                            if (len <= radius && len < close)
                            {
                                close = len;
                                target = i;
                            }
                            break;
                        }
                    }
                    #endregion
                    if (target < Main.npc.Length && Main.npc[target].active)
                    {
                        v.X = Main.npc[target].position.X + (float)(Main.npc[target].width >> 1) - p.position.X + (float)(p.width >> 1);
                        v.Y = Main.npc[target].position.Y + (float)(Main.npc[target].height >> 1) - p.position.Y + (float)(p.height >> 1);
                    }
                    else
                    {
                        target = Main.npc.Length + 1;
                        v.X = p.dest.X - p.position.X + (float)(p.width >> 1);
                        v.Y = p.dest.Y - p.position.Y + (float)(p.height >> 1);
                    }
                    Vector2 nrm = Vector2.Normalize(v);
                    Vector2 dir = Vector2.Normalize(Vector2.Normalize(new Vector2(Main.rand.Next(-100, 100) / 100f, Main.rand.Next(-100, 100) / 100f)) / 6f + nrm);
                    float increment = v.Length() / 3f;
                    p.mainArc[0] = new Vector2(p.position.X + (float)(p.height >> 1), p.position.Y + (float)(p.width >> 1));
                    for (int i = 1; i < p.mainArc.Length; i++)
                    {
                        dir = Vector2.Normalize(dir + nrm);
                        p.mainArc[i] = Vector2.Normalize(dir + Vector2.Normalize(new Vector2(Main.rand.Next(-100, 100) / 120f, Main.rand.Next(-100, 100) / 120f)) * 0.35f) * (increment / (float)i + 1f) + p.mainArc[i - 1];
                    }
                    p.mainArc[p.mainArc.Length - 1] = v + p.position;
                    #region tiles
                    for (int i = 0; i < p.mainArc.Length - 1; i++)
                    {
                        bool exit = false;
                        dir = p.mainArc[i + 1] - p.mainArc[i];
                        float maxLen = dir.Length();
                        dir.Normalize();
                        float tileLen = 0f;

                        int startX = (int)p.mainArc[i].X >> 4;
                        int startY = (int)p.mainArc[i].Y >> 4;

                        while (tileLen < maxLen && !exit)
                        {
                            tileLen += 16f;
                            int tileX = (int)(dir.X * tileLen / 16f) + startX;
                            int tileY = (int)(dir.Y * tileLen / 16f) + startY;
                            if (!electrocute)
                            {
                                if (Main.tile[tileX, tileY].liquid > 0 && !Main.tile[tileX, tileY].lava())
                                {
                                    electrocute = true;
                                    waterX = tileX;
                                    waterY = tileY;
                                }
                            }
                            if (Main.tile[tileX, tileY].active() && Main.tile[tileX, tileY] != null)
                            {
                                if (Main.tileSolid[Main.tile[tileX, tileY].type] && !Main.tileSolidTop[Main.tile[tileX, tileY].type])
                                {
                                    p.mainArc[i + 1].X = (float)(tileX * 16 + 8);
                                    p.mainArc[i + 1].Y = (float)(tileY * 16 + 8);
                                    exit = true;
                                }
                            }
                            if (exit)
                            {
                                target = Main.npc.Length + 1;
                                for (int n = 1; n < p.mainArc.Length - 1; n++)
                                {
                                    if (n > i + 1)
                                    {
                                        p.mainArc[n] = default(Vector2);
                                    }
                                }
                            }
                        }
                    }
                    #endregion
                    int b = 0;
                    increment *= 0.45f;
                    while (b < p.secondaryArc.Length)
                    {
                        for (int i = 1; i < p.mainArc.Length - 1; i++)
                        {
                            // create branch arc
                            if (b < p.secondaryArc.Length && Main.rand.Next(i) > 0)
                            {
                                if (p.mainArc[i] != default(Vector2))
                                {
                                    // set starting point of branch arc
                                    p.secondaryArc[b][0] = p.mainArc[i];

                                    // varset
                                    dir = Vector2.Normalize(Vector2.Normalize(Vector2.Normalize(new Vector2(Main.rand.Next(-100, 100) / 100f, Main.rand.Next(-100, 100) / 100f))) + nrm);

                                    for (int n = 1; n < p.secondaryArc[b].Length; n++)
                                    {
                                        dir = Vector2.Normalize(dir + nrm / 2f);
                                        p.secondaryArc[b][n] = Vector2.Normalize(dir + Vector2.Normalize(Vector2.Normalize(Vector2.Normalize(new Vector2(Main.rand.Next(-100, 100) / 100f, Main.rand.Next(-100, 100) / 100f))))) * (increment / (float)n + 1.25f) + p.secondaryArc[b][n - 1];
                                    }
                                }
                                b++;
                            }
                        }
                    }
                    for (b = 0; b < p.secondaryArc.Length; b++)
                    {
                        for (int i = 0; i < p.secondaryArc[b].Length - 1; i++)
                        {
                            bool exit = false;
                            dir = p.secondaryArc[b][i + 1] - p.secondaryArc[b][i];
                            float maxLen = dir.Length();
                            dir.Normalize();
                            float tileLen = 0f;

                            int startX = (int)p.secondaryArc[b][i].X >> 4;
                            int startY = (int)p.secondaryArc[b][i].Y >> 4;

                            while (tileLen < maxLen && !exit)
                            {
                                tileLen += 16f;
                                int tileX = (int)(dir.X * tileLen / 16f) + startX;
                                int tileY = (int)(dir.Y * tileLen / 16f) + startY;
                                if (Main.tile[tileX, tileY].active() && Main.tile[tileX, tileY] != null)
                                {
                                    if (Main.tileSolid[Main.tile[tileX, tileY].type] && !Main.tileSolidTop[Main.tile[tileX, tileY].type])
                                    {
                                        p.secondaryArc[b][i + 1].X = (float)(tileX * 16 + 8);
                                        p.secondaryArc[b][i + 1].Y = (float)(tileY * 16 + 8);
                                        exit = true;
                                    }
                                }

                                if (exit)
                                {
                                    // break all successive links in the chain
                                    for (int n = 1; n < p.secondaryArc[b].Length - 1; n++)
                                    {
                                        if (n > i + 1)
                                        {
                                            p.secondaryArc[b][n] = default(Vector2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    for (int i = 0; i < p.mainArc.Length - 1; i++)
                    {
                        if (p.mainArc[i + 1] != default(Vector2))
                        {
                            Microsoft.Xna.Framework.Point p1 = new Microsoft.Xna.Framework.Point((int)p.mainArc[i].X, (int)p.mainArc[i].Y);
                            Microsoft.Xna.Framework.Point p2 = new Microsoft.Xna.Framework.Point((int)p.mainArc[i + 1].X, (int)p.mainArc[i + 1].Y);

                            for (int n = 0; n < Main.npc.Length; n++)
                            {
                                // enemies + guide&doll + animals
                                if (!Main.npc[i].friendly)
                                {
                                    Rectangle rect = new Rectangle((int)Main.npc[n].position.X, (int)Main.npc[n].position.Y, Main.npc[n].width, Main.npc[n].height);
                                    if (Ulterraria.LineIntersectsRect(p1, p2, rect))
                                    {
                                        if (target < Main.npc.Length && n == target)
                                        {
                                            // full damage
                                            Ulterraria.DoArcHit(n, 1.0f, p);
                                        }
                                        else
                                        {
                                            // three-quarters damage
                                            Ulterraria.DoArcHit(n, 0.75f, p);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    for (b = 0; b < p.secondaryArc.Length; b++)
                    {
                        for (int i = 0; i < p.secondaryArc[b].Length - 1; i++)
                        {
                            if (p.secondaryArc[b][i + 1] != default(Vector2))
                            {
                                Microsoft.Xna.Framework.Point p1 = new Microsoft.Xna.Framework.Point((int)p.secondaryArc[b][i].X, (int)p.secondaryArc[b][i].Y);
                                Microsoft.Xna.Framework.Point p2 = new Microsoft.Xna.Framework.Point((int)p.secondaryArc[b][i + 1].X, (int)p.secondaryArc[b][i + 1].Y);

                                for (int n = 0; n < Main.npc.Length; n++)
                                {
                                    if (!Main.npc[i].friendly)
                                    {
                                        Rectangle rect = new Rectangle((int)Main.npc[n].position.X, (int)Main.npc[n].position.Y, Main.npc[n].width, Main.npc[n].height);
                                        if (Ulterraria.LineIntersectsRect(p1, p2, rect))
                                        {
                                            // half damage
                                            Ulterraria.DoArcHit(n, 0.5f, p);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (electrocute)
                    {
                        int windowSize = 512 + (p.soundDelay << 2);
                        float centerX = (float)(waterX << 4) + 8f;
                        float centerY = (float)(waterY << 4) + 8f;
                        Rectangle window = new Rectangle((int)centerX - (windowSize >> 1), (int)centerY - (windowSize >> 1), windowSize, windowSize);

                        for (int i = 0; i < Main.npc.Length; i++)
                        {
                            if (!Main.npc[i].friendly)
                            {
                                if (Main.npc[i].wet && !Main.npc[i].lavaWet)
                                {
                                    if (window.Intersects(new Rectangle((int)Main.npc[i].position.X, (int)Main.npc[i].position.Y, Main.npc[i].width, Main.npc[i].height)))
                                    {
                                        if (Collision.CanHit(new Vector2(centerX, centerY), 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height))
                                        {
                                            bool crit = Main.rand.Next(1, 101) <= Main.player[p.owner].magicCrit;
                                            int dmg = Main.DamageVar(((float)(15 + p.soundDelay + Main.rand.Next(p.timeLeft)) * (((float)windowSize - (Main.npc[i].position - new Vector2(centerX, centerY)).Length()) / (float)windowSize)));

                                            Main.npc[i].StrikeNPC(dmg, 0f, 0, crit, true);
                                            Main.npc[i].immune[p.owner] = Main.rand.Next(5, 10);
                                        }
                                    }
                                }
                            }
                        }

                        if (Main.myPlayer == Main.player[p.owner].whoAmI)
                        {
                            if (!Main.player[p.owner].immune && Main.player[p.owner].wet && !Main.player[p.owner].lavaWet)
                            {
                                if (window.Intersects(new Rectangle((int)Main.player[p.owner].position.X, (int)Main.player[p.owner].position.Y, Main.player[p.owner].width, Main.player[p.owner].height)))
                                {
                                    if (Collision.CanHit(new Vector2(centerX, centerY), 1, 1, Main.player[p.owner].position, Main.player[p.owner].width, Main.player[p.owner].height))
                                    {
                                        bool crit = Main.rand.Next(1, 101) <= Main.player[p.owner].magicCrit;
                                        int dmg = Main.DamageVar(((float)(15 + p.soundDelay + Main.rand.Next(p.timeLeft)) * (((float)windowSize - (Main.player[p.owner].position - new Vector2(centerX, centerY)).Length()) / (float)windowSize)));

                                        bool kb = Main.player[p.owner].noKnockback;
                                        Main.player[p.owner].noKnockback = true;
                                        Main.player[p.owner].Hurt(dmg, Main.player[p.owner].direction, false, false, " electrocuted themself...", crit);
                                        Main.player[p.owner].immuneTime = Main.rand.Next(5, 10);
                                        Main.player[p.owner].noKnockback = kb;
                                    }
                                }
                            }
                        }
                    }

                    p.penetrate = 20;
                    p.damage = 0;
                }
                p.ai[0]++;
            }
            else if (p.aiStyle == 131)
            {
                p.ai[0]++;
                if (p.ai[0] > 10)
                {
                    float num472 = p.Center.X;
                    float num473 = p.Center.Y;
                    float num474 = 400f;
                    bool flag17 = false;
                    for (int num475 = 0; num475 < 200; num475++)
                    {
                        if (Main.npc[num475].CanBeChasedBy(p, false) && Collision.CanHit(p.Center, 1, 1, Main.npc[num475].Center, 1, 1))
                        {
                            float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2);
                            float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2);
                            float num478 = Math.Abs(p.position.X + (float)(p.width / 2) - num476) + Math.Abs(p.position.Y + (float)(p.height / 2) - num477);
                            if (num478 < num474)
                            {
                                num474 = num478;
                                num472 = num476;
                                num473 = num477;
                                flag17 = true;
                            }
                        }
                    }
                    if (flag17)
                    {
                        float num483 = 8f;
                        Vector2 vector35 = new Vector2(p.position.X + (float)p.width * 0.5f, p.position.Y + (float)p.height * 0.5f);
                        float num484 = num472 - vector35.X;
                        float num485 = num473 - vector35.Y;
                        float num486 = (float)Math.Sqrt((double)(num484 * num484 + num485 * num485));
                        num486 = num483 / num486;
                        num484 *= num486;
                        num485 *= num486;
                        p.velocity.X = (p.velocity.X * 20f + num484) / 21f;
                        p.velocity.Y = (p.velocity.Y * 20f + num485) / 21f;
                    }
                }
                if (p.ai[0] > 120)
                {
                    p.Kill();
                }
                p.rotation = (float)Math.Atan2(p.velocity.Y, p.velocity.X) + (float)(Math.PI / 2);
            }
            else if (p.aiStyle == 132)
            {
                p.velocity *= 0.95f;
                p.ai[0] += 1f;
                if (p.ai[0] == 180f)
                {
                    p.Kill();
                }
                if (p.ai[1] == 0f)
                {
                    p.ai[1] = 1f;
                    for (int num62 = 0; num62 < 30; num62++)
                    {
                        int du = Dust.NewDust(p.position, p.width, p.height, 152 + Main.rand.Next(0, 2), p.velocity.X, p.velocity.Y, 50, default(Color), 1f);
                    }
                }
                int num63 = (int)(p.position.X / 16f) - 1;
                int num64 = (int)((p.position.X + (float)p.width) / 16f) + 2;
                int num65 = (int)(p.position.Y / 16f) - 1;
                int num66 = (int)((p.position.Y + (float)p. height) / 16f) + 2;
                if (num63 < 0)
                {
                    num63 = 0;
                }
                if (num64 > Main.maxTilesX)
                {
                    num64 = Main.maxTilesX;
                }
                if (num65 < 0)
                {
                    num65 = 0;
                }
                if (num66 > Main.maxTilesY)
                {
                    num66 = Main.maxTilesY;
                }
                for (int num67 = num63; num67 < num64; num67++)
                {
                    for (int num68 = num65; num68 < num66; num68++)
                    {
                        Vector2 vector5;
                        vector5.X = (float)(num67 * 16);
                        vector5.Y = (float)(num68 * 16);
                        if (p.position.X + (float)p.width > vector5.X && p.position.X < vector5.X + 16f && p.position.Y + (float)p.height > vector5.Y && p.position.Y < vector5.Y + 16f && Main.myPlayer == p.owner && !Main.tile[num67, num68].active())
                        {
                            if (Main.tile[num67, num68] == null)
                            {
                                Main.tile[num67, num68] = new Tile();
                            }
                            if (Main.tile[num67, num68 + 1] == null)
                            {
                                Main.tile[num67, num68 + 1] = new Tile();
                            }
                            if (Main.tile[num67, num68].type != 3 || Main.tile[num67, num68].type != 73 || Main.tile[num67, num68].type != 110 || Main.tile[num67, num68].type != 113 || Main.tile[num67, num68].type != 74)
                            {
                                if (!Main.tile[num67, num68].active() && Main.tile[num67, num68].liquid == 0 && Main.tile[num67, num68 + 1] != null && WorldGen.SolidTile(num67, num68 + 1))
                                {
                                    Main.tile[num67, num68].frameY = 0;
                                    Main.tile[num67, num68].slope(0);
                                    Main.tile[num67, num68].halfBrick(false);
                                    if (Main.tile[num67, num68 + 1].type == 2)
                                    {
                                        if (Main.rand.Next(2) == 0)
                                        {
                                            Main.tile[num67, num68].active(true);
                                            Main.tile[num67, num68].type = 3;
                                            Main.tile[num67, num68].frameX = (short)(18 * Main.rand.Next(6, 11));
                                            while (Main.tile[num67, num68].frameX == 144)
                                            {
                                                Main.tile[num67, num68].frameX = (short)(18 * Main.rand.Next(6, 11));
                                            }
                                        }
                                        else
                                        {
                                            Main.tile[num67, num68].active(true);
                                            Main.tile[num67, num68].type = 73;
                                            Main.tile[num67, num68].frameX = (short)(18 * Main.rand.Next(6, 21));
                                            while (Main.tile[num67, num68].frameX == 144)
                                            {
                                                Main.tile[num67, num68].frameX = (short)(18 * Main.rand.Next(6, 21));
                                            }
                                        }
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    else if (Main.tile[num67, num68 + 1].type == 109)
                                    {
                                        if (Main.rand.Next(2) == 0)
                                        {
                                            Main.tile[num67, num68].active(true);
                                            Main.tile[num67, num68].type = 110;
                                            Main.tile[num67, num68].frameX = (short)(18 * Main.rand.Next(4, 7));
                                            while (Main.tile[num67, num68].frameX == 90)
                                            {
                                                Main.tile[num67, num68].frameX = (short)(18 * Main.rand.Next(4, 7));
                                            }
                                        }
                                        else
                                        {
                                            Main.tile[num67, num68].active(true);
                                            Main.tile[num67, num68].type = 113;
                                            Main.tile[num67, num68].frameX = (short)(18 * Main.rand.Next(2, 8));
                                            while (Main.tile[num67, num68].frameX == 90)
                                            {
                                                Main.tile[num67, num68].frameX = (short)(18 * Main.rand.Next(2, 8));
                                            }
                                        }
                                        
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    else if (Main.tile[num67, num68 + 1].type == 60)
                                    {
                                        Main.tile[num67, num68].active(true);
                                        Main.tile[num67, num68].type = 74;
                                        Main.tile[num67, num68].frameX = (short)(18 * Main.rand.Next(9, 17));
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    p.Kill();
                                }
                            }
                        }
                    }
                }
            }
            else if (p.aiStyle == 133)
            {
                if (p.ai[0] == 0 && p.type == 697)
                {
                    for (int e = 0; e < Main.projectile.Length; e++)
                    {
                        if (Main.projectile[e].type == 698)
                        {
                            Main.projectile[e].Kill();
                        }
                    }
                    Vector2[] circularPositions = new Vector2[60];
                    for (int i = 0; i < 60; i++)
                    {
                        p.circularAngle += (float)((2 * Math.PI) / 60);
                        circularPositions[i] = new Vector2((float)Math.Cos(p.circularAngle) * 120 + Main.player[Main.myPlayer].Center.X - 10, (float)Math.Sin(p.circularAngle) * 120 + Main.player[Main.myPlayer].Center.Y - 10);
                    }
                    foreach (Vector2 Cen in circularPositions)
                    {
                        Projectile.NewProjectile(Cen.X, Cen.Y, 0f, 0f, 698, 48, 10f, Main.myPlayer);
                    }
                }
                else if (p.type == 697)
                {
                    p.Kill();
                }
                p.ai[0]++;
                if (p.type == 698)
                {
                    if (p.ai[0] < 3600)
                    {
                        for (int l = 0; l < 2; l++)
                        {
                            int n = Dust.NewDust(p.Center, p.width, p.height, 75, 0f, 0f, 100, default(Color), 1f);
                            Main.dust[n].noGravity = true;
                        }
                    }
                    else
                    {
                        p.Kill();
                    }
                }
            }
            else if (p.aiStyle == 134)
            {
                p.velocity.Y += 0.04f;
                p.rotation = (float)Math.Atan2((double)p.velocity.Y, (double)p.velocity.X);
            }
            else if (p.aiStyle == 135)
            {
                p.frameCounter++;
                if (p.frameCounter > 5)
                {
                    p.frame++;
                    p.frameCounter = 0;
                }
                if (p.frame > 3)
                {
                    p.frame = 0;
                }
                p.rotation = (float)Math.Atan2((double)p.velocity.Y, (double)p.velocity.X);
                p.rotation += (float)(Math.PI / 2);
                if (p.type == 700)
                {
                    p.ai[0]++;
                    if (p.ai[0] > 94)
                    {
                        p.alpha += 10;
                        if (p.alpha > 255)
                        {
                            p.Kill();
                        }
                    }
                    if (p.ai[0] % 10 == 0)
                    {
                        float amount = MathHelper.ToRadians(Main.rand.Next(-360, 361));
                        Vector2 newVelocity = new Vector2((float)Math.Cos(p.rotation + amount), (float)Math.Sin(p.rotation + amount));
                        newVelocity *= 9f;
                        Projectile.NewProjectile(p.Center.X, p.Center.Y, -newVelocity.X, -newVelocity.Y, 701, 78, 2f, Main.myPlayer);
                    }
                }
                else if (p.type == 701)
                {
                    p.ai[0]++;
                    if (p.ai[0] > 94)
                    {
                        p.alpha += 10;
                        if (p.alpha > 255)
                        {
                            p.Kill();
                        }
                    }
                }
            }
            else if (p.aiStyle == 136)
            {
                p.frameCounter++;
                if (p.frameCounter > 5)
                {
                    p.frame++;
                    p.frameCounter = 0;
                }
                if (p.frame > 3)
                {
                    p.frame = 0;
                }
                p.rotation = (float)Math.Atan2(p.velocity.Y, p.velocity.X);
                p.alpha += 9;
                if (p.alpha > 255)
                {
                    p.Kill();
                }
            }
            else if (p.aiStyle == 137)
            {
                p.frameCounter++;
                if (p.frameCounter > 4)
                {
                    p.frame++;
                    p.frameCounter = 0;
                }
                if (p.frame > 1)
                {
                    p.frame = 0;
                }
                p.rotation = (float)Math.Atan2(p.velocity.Y, p.velocity.X);
                float num472 = p.Center.X;
                float num473 = p.Center.Y;
                float num474 = 400f;
                bool flag17 = false;
                for (int num475 = 0; num475 < 200; num475++)
                {
                    if (Main.npc[num475].CanBeChasedBy(p, false) && Collision.CanHit(p.Center, 1, 1, Main.npc[num475].Center, 1, 1))
                    {
                        float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2);
                        float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2);
                        float num478 = Math.Abs(p.position.X + (float)(p.width / 2) - num476) + Math.Abs(p.position.Y + (float)(p.height / 2) - num477);
                        if (num478 < num474)
                        {
                            num474 = num478;
                            num472 = num476;
                            num473 = num477;
                            flag17 = true;
                        }
                    }
                }
                if (flag17)
                {
                    float num483 = 8f;
                    Vector2 vector35 = new Vector2(p.position.X + (float)p.width * 0.5f, p.position.Y + (float)p.height * 0.5f);
                    float num484 = num472 - vector35.X;
                    float num485 = num473 - vector35.Y;
                    float num486 = (float)Math.Sqrt((double)(num484 * num484 + num485 * num485));
                    num486 = num483 / num486;
                    num484 *= num486;
                    num485 *= num486;
                    p.velocity.X = (p.velocity.X * 20f + num484) / 21f;
                    p.velocity.Y = (p.velocity.Y * 20f + num485) / 21f;
                    return;
                }
            }
            else if (p.aiStyle == 138)
            {
                p.frameCounter++;
                if (p.frameCounter > 5)
                {
                    p.frame++;
                    p.frameCounter = 0;
                }
                if (p.frame >= Main.projFrames[p.type])
                {
                    p.frame = 0;
                    return;
                }
                p.ai[1]++;
                if (p.ai[1] > 540)
                {
                    p.alpha += 3;
                    if (p.alpha > 255)
                    {
                        p.Kill();
                    }
                }
            }
            else if (p.aiStyle == 139)
            {
                p.frameCounter++;
                if (p.frameCounter > 5)
                {
                    p.frame++;
                    p.frameCounter = 0;
                }
                if (p.frame >= Main.projFrames[p.type])
                {
                    p.frame = 0;
                    return;
                }
                p.rotation = (float)Math.Atan2(p.velocity.Y, p.velocity.X);
                p.rotation -= (float)(Math.PI / 2);
                p.ai[1]++;
                if (p.ai[1] > 140)
                {
                    p.alpha += 2;
                    if (p.alpha > 255)
                    {
                        p.Kill();
                    }
                }
                int dustType = Utils.SelectRandom<int>(Main.rand, new int[]
				{
					242,
					73,
					72,
					71,
					255
				});
                if (p.type == 706)
                {
                    dustType = Utils.SelectRandom<int>(Main.rand, new int[]
					{
						242,
						59,
						88
					});
                }
                if (Main.rand.Next(12) == 0)
                {
                    for (int num42 = 0; num42 < 1; num42++)
                    {
                        Vector2 value9 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)p.velocity.ToRotation(), default(Vector2));
                        int num43 = Dust.NewDust(p.position, p.width, p.height, 31, 0f, 0f, 100, default(Color), 1f);
                        Main.dust[num43].velocity *= 0.1f;
                        Main.dust[num43].position = p.Center + value9 * (float)p.width / 2f + p.velocity * 2f;
                        Main.dust[num43].fadeIn = 0.9f;
                    }
                }
                if (Main.rand.Next(64) == 0)
                {
                    for (int num44 = 0; num44 < 1; num44++)
                    {
                        Vector2 value10 = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)p.velocity.ToRotation(), default(Vector2));
                        int num45 = Dust.NewDust(p.position, p.width, p.height, 31, 0f, 0f, 155, default(Color), 0.8f);
                        Main.dust[num45].velocity *= 0.3f;
                        Main.dust[num45].position = p.Center + value10 * (float)p.width / 2f;
                        if (Main.rand.Next(2) == 0)
                        {
                            Main.dust[num45].fadeIn = 1.4f;
                        }
                    }
                }
                if (Main.rand.Next(4) == 0)
                {
                    for (int num46 = 0; num46 < 2; num46++)
                    {
                        Vector2 value11 = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy((double)p.velocity.ToRotation(), default(Vector2));
                        int num47 = Dust.NewDust(p.position, p.width, p.height, dustType, 0f, 0f, 0, default(Color), 1.2f);
                        Main.dust[num47].velocity *= 0.3f;
                        Main.dust[num47].noGravity = true;
                        Main.dust[num47].position = p.Center + value11 * (float)p.width / 2f;
                        if (Main.rand.Next(2) == 0)
                        {
                            Main.dust[num47].fadeIn = 1.4f;
                        }
                    }
                }
                if (Main.rand.Next(12) == 0 && p.type == 634)
                {
                    Vector2 value12 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)p.velocity.ToRotation(), default(Vector2));
                    int num48 = Dust.NewDust(p.position, p.width, p.height, dustType, 0f, 0f, 100, default(Color), 1f);
                    Main.dust[num48].velocity *= 0.3f;
                    Main.dust[num48].position = p.Center + value12 * (float)p.width / 2f;
                    Main.dust[num48].fadeIn = 0.9f;
                    Main.dust[num48].noGravity = true;
                }
                if (Main.rand.Next(3) == 0 && p.type == 635)
                {
                    Vector2 value13 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)p.velocity.ToRotation(), default(Vector2));
                    int num49 = Dust.NewDust(p.position, p.width, p.height, dustType, 0f, 0f, 100, default(Color), 1f);
                    Main.dust[num49].velocity *= 0.3f;
                    Main.dust[num49].position = p.Center + value13 * (float)p.width / 2f;
                    Main.dust[num49].fadeIn = 1.2f;
                    Main.dust[num49].scale = 1.5f;
                    Main.dust[num49].noGravity = true;
                }
            }
            else if (p.aiStyle == 140)
            {
                p.velocity.Y += 0.09f;
                p.rotation += 0.19703424f;
                for (int i = 0; i < 200; i++)
                {
                    Rectangle r = new Rectangle((int)Main.npc[i].position.X, (int)Main.npc[i].position.Y, Main.npc[i].width, Main.npc[i].height);
                    if (r.Intersects(new Rectangle((int)p.position.X, (int)p.position.Y, p.width, p.height)))
                    {
                        p.Center = Main.npc[i].Center;
                        if (Main.npc[i].life <= 0)
                        {
                            p.Kill();
                        }
                    }
                }
            }
            else if (p.aiStyle == 141)
            {
                if (p.type == 713)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        int d = Dust.NewDust(p.Center, 0, 0, 272 + Main.rand.Next(0, 7), 0f, 0f, 50, default(Color), 1.13f);
                        Main.dust[d].noGravity = true;
                        Main.dust[d].velocity = new Vector2(0f, 0f);
                    }
                }
                else if (p.type == 714)
                {
                    p.rotation = (float)Math.Atan2(p.velocity.Y, p.velocity.X);
                    Lighting.AddLight(p.Center, new Vector3(0.384f, 0.081f, 0.687f));
                }
                else if (p.type == 715)
                {
                    p.rotation = (float)Math.Atan2(p.velocity.Y, p.velocity.X);
                    Lighting.AddLight(p.Center, new Vector3(0.057f, 0.564f, 0.708f));
                }
                else if (p.type == 716 || p.type == 717)
                {
                    p.rotation = (float)Math.Atan2(p.velocity.Y, p.velocity.X);
                    p.ai[0]++;
                    if (p.ai[0] > 15)
                    {
                        p.Kill();
                    }
                }
            }
            else if (p.aiStyle == 142)
            {
                p.rotation = (float)Math.Atan2(p.velocity.Y, p.velocity.X) - (float)Math.PI / 2 - (float)Math.PI / 4;
                p.velocity.Y += 0.12f;
            }
            else if (p.aiStyle == 143)
            {
                if (Main.player[p.owner].dead)
                {
                    p.Kill();
                    return;
                }
                Vector2 mountedCenter2 = Main.player[p.owner].MountedCenter + new Vector2(Main.player[p.owner].direction * 10, 3);
                Vector2 vector18 = new Vector2(p.position.X + (float)p.width * 0.5f, p.position.Y + (float)p.height * 0.5f);
                float num204 = mountedCenter2.X - vector18.X;
                float num205 = mountedCenter2.Y - vector18.Y;
                float num206 = (float)Math.Sqrt((double)(num204 * num204 + num205 * num205));
                if (p.ai[0] == 0f)
                {
                    float num207 = 160f;
                    p.tileCollide = true;
                    if (num206 > num207)
                    {
                        p.ai[0] = 1f;
                        p.netUpdate = true;
                    }
                    else if (!Main.player[p.owner].channel)
                    {
                        if (p.velocity.Y < 0f)
                        {
                            p.velocity.Y = p.velocity.Y * 0.9f;
                        }
                        p.velocity.Y = p.velocity.Y + 1f;
                        p.velocity.X = p.velocity.X * 0.9f;
                    }
                }
                else if (p.ai[0] == 1f)
                {
                    float num208 = 14f / Main.player[p.owner].meleeSpeed;
                    float num209 = 0.9f / Main.player[p.owner].meleeSpeed;
                    float num210 = 300f;
                    Math.Abs(num204);
                    Math.Abs(num205);
                    if (p.ai[1] == 1f)
                    {
                        p.tileCollide = false;
                    }
                    if (!Main.player[p.owner].channel || num206 > num210 || !p.tileCollide)
                    {
                        p.ai[1] = 1f;
                        if (p.tileCollide)
                        {
                            p.netUpdate = true;
                        }
                        p.tileCollide = false;
                    }
                    if (!p.tileCollide)
                    {
                        num209 *= 2f;
                    }
                    int num211 = 60;
                    if (num206 > (float)num211 || !p.tileCollide)
                    {
                        num206 = num208 / num206;
                        num204 *= num206;
                        num205 *= num206;
                        new Vector2(p.velocity.X, p.velocity.Y);
                        float num212 = num204 - p.velocity.X;
                        float num213 = num205 - p.velocity.Y;
                        float num214 = (float)Math.Sqrt((double)(num212 * num212 + num213 * num213));
                        num214 = num209 / num214;
                        num212 *= num214;
                        num213 *= num214;
                        p.velocity.X = p.velocity.X * 0.98f;
                        p.velocity.Y = p.velocity.Y * 0.98f;
                        p.velocity.X = p.velocity.X + num212;
                        p.velocity.Y = p.velocity.Y + num213;
                    }
                    else
                    {
                        if (Math.Abs(p.velocity.X) + Math.Abs(p.velocity.Y) < 6f)
                        {
                            p.velocity.X = p.velocity.X * 0.96f;
                            p.velocity.Y = p.velocity.Y + 0.2f;
                        }
                        if (Main.player[p.owner].velocity.X == 0f)
                        {
                            p.velocity.X = p.velocity.X * 0.96f;
                        }
                    }
                }
                p.rotation = (float)Math.Atan2((double)num205, (double)num204) - p.velocity.X * 0.1f;
                if (p.velocity.X < 0f)
                {
                    p.rotation -= (Math.Abs(p.velocity.X) + Math.Abs(p.velocity.Y)) * 0.01f;
                }
                else
                {
                    p.rotation += (Math.Abs(p.velocity.X) + Math.Abs(p.velocity.Y)) * 0.01f;
                }
            }
            else if (p.aiStyle == 144)
            {
                p.rotation += (float)(Math.PI / 45);
                if (p.type != 725)
                {
                    p.velocity.Y += 0.13f;
                }
                if (p.type == 725)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        int d = Dust.NewDust(p.Center, p.width, p.height, 21);
                        Main.dust[d].noGravity = true;
                    }
                }
                if (p.type == 739)
                {
                    float num472 = p.Center.X;
                    float num473 = p.Center.Y;
                    float num474 = 400f;
                    bool flag17 = false;
                    for (int num475 = 0; num475 < 200; num475++)
                    {
                        if (Main.npc[num475].CanBeChasedBy(p, false) && Collision.CanHit(p.Center, 1, 1, Main.npc[num475].Center, 1, 1))
                        {
                            float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2);
                            float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2);
                            float num478 = Math.Abs(p.position.X + (float)(p.width / 2) - num476) + Math.Abs(p.position.Y + (float)(p.height / 2) - num477);
                            if (num478 < num474)
                            {
                                num474 = num478;
                                num472 = num476;
                                num473 = num477;
                                flag17 = true;
                            }
                        }
                    }
                    if (flag17)
                    {
                        float num483 = 8f;
                        Vector2 vector35 = new Vector2(p.position.X + (float)p.width * 0.5f, p.position.Y + (float)p.height * 0.5f);
                        float num484 = num472 - vector35.X;
                        float num485 = num473 - vector35.Y;
                        float num486 = (float)Math.Sqrt((double)(num484 * num484 + num485 * num485));
                        num486 = num483 / num486;
                        num484 *= num486;
                        num485 *= num486;
                        p.velocity.X = (p.velocity.X * 20f + num484) / 21f;
                        p.velocity.Y = (p.velocity.Y * 20f + num485) / 21f;
                        return;
                    }
                }
            }
            else if (p.aiStyle == 145)
            {
                if (p.type != 761)
                {
                    p.rotation += (float)Math.PI / 90;
                    p.velocity.Y += 0.125f;
                    if (p.type == 751)
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            int dus = Dust.NewDust(new Vector2(p.Center.X - 2, p.Center.Y - 2), 4, 4, 279);
                            Main.dust[dus].noGravity = true;
                        }
                    }
                }
                else
                {
                    p.frameCounter++;
                    if (p.frameCounter > 6)
                    {
                        p.frame++;
                        if (p.frame > 3)
                        {
                            p.frame = 0;
                        }
                        p.frameCounter = 0;
                    }
                    p.ai[0]++;
                    if (p.ai[0] > 210)
                    {
                        p.alpha += 10;
                        if (p.alpha > 255)
                        {
                            p.Kill();
                        }
                    }
                }
            }
            else if (p.aiStyle == 146)
            {
                if (p.type == 774)
                {
                    p.rotation += 0 + ((float)Math.Sqrt(Math.Pow(p.velocity.X, 2) * Math.Pow(p.velocity.Y, 2)) * 0.12f);
                    p.velocity *= 0.98f;
                    if ((p.velocity.X < 1f && p.velocity.X > -1f) && (p.velocity.Y < 1f && p.velocity.Y > -1f))
                    {
                        p.ai[0]++;
                        if (p.ai[0] > 30)
                        {
                            p.scale *= 0.96f;
                            p.alpha += 15;
                            if (p.alpha > 255)
                            {
                                p.ai[1]++;
                                if (p.ai[1] > 20)
                                {
                                    p.Kill();
                                    for (int i = 0; i < 40; i++)
                                    {
                                        int side = Main.rand.Next(-12, 13);
                                        if (Main.rand.Next(0, 2) == 0)
                                        {
                                            Vector2 dustPos = p.Center + new Vector2(side, Main.rand.Next(-12, 13));
                                            Vector2 speed = dustPos - p.Center;
                                            Dust.NewDust(dustPos, 1, 1, 76, speed.X, speed.Y);
                                        }
                                        else
                                        {
                                            Vector2 dustPos = p.Center + new Vector2(Main.rand.Next(-12, 13), side);
                                            Vector2 speed = dustPos - p.Center;
                                            Dust.NewDust(dustPos, 1, 1, 76, speed.X, speed.Y);
                                        }
                                        side = Main.rand.Next(-20, 21);
                                        if (Main.rand.Next(0, 2) == 0)
                                        {
                                            Vector2 dustPos = p.Center + new Vector2(side, Main.rand.Next(-20, 21));
                                            Vector2 speed = dustPos - p.Center;
                                            Dust.NewDust(dustPos, 1, 1, 76, speed.X, speed.Y);
                                        }
                                        else
                                        {
                                            Vector2 dustPos = p.Center + new Vector2(Main.rand.Next(-20, 21), side);
                                            Vector2 speed = dustPos - p.Center;
                                            Dust.NewDust(dustPos, 1, 1, 76, speed.X, speed.Y);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (p.type == 775)
                {
                    p.velocity.Y += 0.115f;
                    p.rotation = p.velocity.ToRotation();
                    p.frameCounter++;
                    if (p.frameCounter > 7)
                    {
                        p.frameCounter = 0;
                        p.frame++;
                        if (p.frame > 2)
                        {
                            p.frame = 0;
                        }
                    }
                }
                if (p.type == 811)
                {
                    p.rotation = p.velocity.ToRotation();
                    if (p.ai[0] >= 0)
                        p.ai[0]++;
                    if (p.ai[0] == 20)
                    {
                        p.ai[1] = p.velocity.X * -1;
                        p.ai[2] = p.velocity.Y * -1;
                    }
                    if (p.ai[0] > 20)
                    {
                        p.velocity *= 0.975f;
                        if (p.velocity.X < 0.3f && p.velocity.X > -0.3f && p.velocity.Y > -0.3f && p.velocity.Y < 0.3f)
                        {
                            p.velocity = new Vector2(p.ai[1], p.ai[2]);
                            p.ai[0] = -200;
                        }
                    }
                    p.frameCounter++;
                    if (p.frameCounter > 7)
                    {
                        p.frameCounter = 0;
                        p.frame++;
                        if (p.frame > 2)
                        {
                            p.frame = 0;
                        }
                    }
                }
            }
            else if (p.aiStyle == 147)
            {
                p.rotation = p.velocity.ToRotation();
                p.ai[1] += 1f;
                if (p.ai[1] > 4f)
                {
                    int dustType = Utils.SelectRandom<int>(Main.rand, new int[] { 56, 60, 66 });
                    int num356 = Dust.NewDust(new Vector2(p.position.X + 2f, p.position.Y), 8, 8, dustType, p.velocity.X, p.velocity.Y, 100, default(Color), 1.2f);
                    Main.dust[num356].noGravity = true;
                    Main.dust[num356].velocity *= 0.2f;
                    Main.dust[num356].position = Main.dust[num356].position.RotatedBy((double)p.rotation, p.Center);
                }
                float num472 = p.Center.X;
                float num473 = p.Center.Y;
                float num474 = 200f;
                bool flag17 = false;
                for (int num475 = 0; num475 < 200; num475++)
                {
                    if (Main.npc[num475].CanBeChasedBy(p, false) && Collision.CanHit(p.Center, 1, 1, Main.npc[num475].Center, 1, 1))
                    {
                        float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2);
                        float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2);
                        float num478 = Math.Abs(p.position.X + (float)(p.width / 2) - num476) + Math.Abs(p.position.Y + (float)(p.height / 2) - num477);
                        if (num478 < num474)
                        {
                            num474 = num478;
                            num472 = num476;
                            num473 = num477;
                            flag17 = true;
                        }
                    }
                }
                if (flag17)
                {
                    float num483 = 6f;
                    Vector2 vector35 = new Vector2(p.position.X + (float)p.width * 0.5f, p.position.Y + (float)p.height * 0.5f);
                    float num484 = num472 - vector35.X;
                    float num485 = num473 - vector35.Y;
                    float num486 = (float)Math.Sqrt((double)(num484 * num484 + num485 * num485));
                    num486 = num483 / num486;
                    num484 *= num486;
                    num485 *= num486;
                    p.velocity.X = (p.velocity.X * 20f + num484) / 21f;
                    p.velocity.Y = (p.velocity.Y * 20f + num485) / 21f;
                    return;
                }
            }
            else if (p.aiStyle == 148)
            {
                if (p.type == 769)
                {
                    p.rotation = p.velocity.ToRotation() + (float)(Math.PI / 2);
                    return;
                }
                NPC npc = Main.npc[(int)p.ai[0]];
                if (p.ai[2] == 0)
                {
                    p.ai[2]++;
                    Vector2 pos = p.Center - npc.Center;
                    p.ai[3] = pos.X;
                    p.ai[4] = pos.Y;
                }
                Vector2 position = npc.Center + new Vector2(p.ai[3], p.ai[4]);
                p.Center = position.RotatedBy(npc.rotation, npc.Center);
                if (!npc.active || npc.life <= 0)
                {
                    p.Kill();
                    return;
                }
            }
            else if (p.aiStyle == 149)
            {
                if (p.type == 856)
                {
                    p.ai[0]++;
                    if (p.ai[0] % 40 == 0)
                    {
                        p.ai[1]++;
                        p.ai[0] = 0;
                        UlterrariaProjectiles.ExplosionEffect(p);
                        p.width = 75;
                        p.height = 75;
                        p.position.X -= 37.5f;
                        p.position.Y -= 37.5f;
                        p.damage = 70;
                        p.Damage();
                        p.width = 14;
                        p.height = 20;
                        p.position.X += 37.5f;
                        p.position.Y += 37.5f;
                    }
                    if (p.ai[1] >= 3)
                    {
                        p.Kill();
                    }
                }
                //---------------
                if (p.type == 843)
                {
                    if (p.ai[0] == 0)
                    {
                        if (p.velocity.X > 0)
                        {
                            p.ai[0] = 0.005f;
                        }
                        else
                        {
                            p.ai[0] = -0.005f;
                        }
                        Vector2 position = p.Center - (p.Center + new Vector2(-2, 6));
                        p.ai[2] = position.X;
                        p.ai[3] = position.Y;
                    }
                    p.ai[1] += p.ai[0];
                    p.rotation += p.ai[1];
                    p.ai[4]++;
                    if (p.ai[4] > Main.rand.Next(120, 180))
                    {
                        p.Kill();
                    }
                    for (int i = 0; i < p.ai[0] * 100; i++)
                    {
                        Vector2 pos = p.Center + new Vector2(p.ai[2], p.ai[3]);
                        Vector2 center = pos.RotatedBy(p.rotation, p.Center);
                        int du = Dust.NewDust(center, 3, 2, 6, 0.1f, 0.1f);
                        Main.dust[du].noGravity = true;
                    }
                }
                //-----------------
                if (p.type == 842)
                {
                    if (p.ai[0] == 0)
                    {
                        p.ai[0]++;
                        p.velocity *= 1.2f;
                    }
                    p.rotation += p.velocity.X * 0.02f;
                }
                //----------------
                if (p.type == 832)
                {
                    p.frameCounter++;
                    if (p.frameCounter > 6)
                    {
                        p.frameCounter = 0;
                        p.frame++;
                        if (p.frame > 5)
                        {
                            p.Kill();
                        }
                    }
                }
                //-----------------
                if (p.type == 831)
                {
                    if (p.ai[0] == 0)
                    {
                        p.ai[1] = p.velocity.X * 1.8f;
                        p.ai[2] = p.velocity.Y * 1.8f;
                        p.rotation = p.velocity.ToRotation() + ((float)(Math.PI / 4));
                    }
                    p.ai[0]++;
                    if (p.ai[0] < 30)
                    {
                        p.velocity *= 0.94f;
                    }
                    if (p.ai[0] == 30)
                    {
                        p.velocity = Vector2.Zero;
                    }
                    if (p.ai[0] > 60)
                    {
                        p.velocity = new Vector2(p.ai[1], p.ai[2]);
                        p.rotation = p.velocity.ToRotation() + ((float)(Math.PI / 4));
                    }
                    for (int i = 0; i < (int)(p.velocity.Length() / 2); i++)
                    {
                        int d = Dust.NewDust(p.Center, 0, 0, 107);
                        Main.dust[d].noGravity = true;
                    }
                }
                //-----------------
                if (p.type == 830)
                {
                    //p.ai[1] is the angle to increase every frame
                    //p.ai[2] is the distance from the player
                    if (p.ai[0] == 0)
                    {
                        p.ai[0]++;
                        p.ai[1] = 5f;
                        p.ai[2] = 30;
                        p.ai[3] = Main.rand.Next(2);
                        p.circularAngle = -5f;
                    }
                    p.ai[0]++;
                    if (p.ai[0] > 360)
                    {
                        p.alpha += 5;
                        if (p.alpha > 255)
                        {
                            p.Kill();
                        }
                    }
                    float speed = ((float)(Math.PI) / 180) * p.ai[1];
                    float radius = p.ai[2];
                    p.circularAngle += speed;
                    p.Center = new Vector2((float)Math.Cos(p.circularAngle) * radius + Main.player[p.owner].Center.X, (float)Math.Sin(p.circularAngle) * radius + Main.player[p.owner].Center.Y);
                    p.ai[1] += 0.012f;
                    p.ai[2] += 0.6f;
                    p.rotation += p.ai[3] == 0 ? ((float)(Math.PI) / 180) * 1 : ((float)(Math.PI) / 180) * -1;
                }
                //------------------
                if (p.type == 825 || p.type == 826 || p.type == 827 || p.type == 828 || p.type == 829 || p.type == 833 || p.type == 834 || p.type == 835 || (p.type >= 836 && p.type <= 838))
                {
                    p.rotation = p.velocity.ToRotation() + (float)(Math.PI / 2);
                    if (p.type == 828 || p.type == 829)
                    {
                        p.velocity.Y += 0.145f;
                    }
                    if (p.type == 834)
                    {
                        p.ai[0]++;
                        if (p.ai[0] > 10)
                        {
                            Projectile.NewProjectile(p.Center.X, p.Center.Y, 0, 0, 835, (int)(p.damage * 0.90), 0);
                        }
                    }
                    if (p.type == 835)
                    {
                        int du = Dust.NewDust(p.position, p.width, p.height, 261, 0f, 0f);
                        Main.dust[du].noGravity = true;
                    }
                    if (p.type == 836)
                    {
                        p.frameCounter++;
                        if (p.frameCounter > 5)
                        {
                            p.frame++;
                            p.frameCounter = 0;
                            if (p.frame > 3)
                            {
                                p.frame = 0;
                            }
                        }
                        if (p.ai[0] == 0)
                        {
                            p.velocity.X = 0;
                            p.velocity.Y = -3;
                        }
                        for (int i = 0; i < 2; i++)
                        {
                            int du = Dust.NewDust(p.Center, 0, 0, 41, 0, 0);
                            Main.dust[du].noGravity = true;
                        }
                        p.ai[0]++;
                        if (p.ai[0] > 120)
                        {
                            p.velocity *= 0.93f;
                            p.alpha += 10;
                            if (p.alpha > 255)
                            {
                                p.Kill();
                            }
                        }
                    }
                    if (p.type == 837)
                    {
                        int du = Dust.NewDust(p.Center, 0, 0, 41, 0, 0);
                        Main.dust[du].noGravity = true;
                        p.frameCounter++;
                        if (p.frameCounter > 5)
                        {
                            p.frame++;
                            p.frameCounter = 0;
                            if (p.frame > 3)
                            {
                                p.frame = 0;
                            }
                        }
                    }
                    if (p.type == 838)
                    {
                        int du = Dust.NewDust(p.Center, 0, 0, 41, 0, 0);
                        Main.dust[du].noGravity = true;
                        p.frameCounter++;
                        if (p.frameCounter > 6)
                        {
                            p.frame++;
                            p.frameCounter = 0;
                            if (p.frame > 2)
                            {
                                p.frame = 0;
                            }
                        }
                    }
                }
                //------------------
                if (p.type == 817)
                {
                    if (p.ai[3] == 0)
                    {
                        p.ai[3] = 1;
                        Color color = Ulterraria.RainbowColor[Main.rand.Next(0, Ulterraria.rainbow.Length)];
                        p.ai[16] = color.R;
                        p.ai[17] = color.G;
                        p.ai[18] = color.B;
                    }
                    p.rotation = p.velocity.ToRotation();
                }
                //------------------
                if (p.type == 813)
                {
                    if (p.ai[0] == 0)
                    {
                        p.ai[0] = 1;
                        p.scale = Main.rand.Next(80, 121) / 100;
                    }
                    p.frameCounter++;
                    if (p.frameCounter > 7)
                    {
                        p.frame++;
                        if (p.frame > 3)
                        {
                            p.Kill();
                        }
                    }
                }
                //------------------
                if (p.type == 812)
                {
                    p.velocity *= 0.96f;
                    p.rotation += p.velocity.X * 0.01f;
                    if (Main.rand.Next(8) == 0)
                    {
                        Projectile.NewProjectile(p.Center.X + Main.rand.Next(-100, 101), p.Center.Y + Main.rand.Next(-100, 101), 0f, 0f, 813, 37, 0f);
                    }
                    if (p.velocity.X >= -1 && p.velocity.X <= 1 && p.velocity.Y <= 1 && p.velocity.Y >= -1)
                    {
                        p.alpha += 51;
                        if (p.alpha >= 255)
                        {
                            p.Kill();
                        }
                    }
                }
                //---------------------
                if (p.type == 808)
                {
                    p.rotation = p.velocity.ToRotation() - (float)((Math.PI / 4f) * 3f);
                }
                //---------------------
                if (p.type == 807)
                {
                    p.rotation += 0.02f;
                    p.velocity *= 0.99f;
                    if (p.velocity.X <= 1 && p.velocity.X >= -1 && p.velocity.Y <= 1 && p.velocity.Y >= -1)
                    {
                        p.alpha += 17;
                        if (p.alpha >= 255)
                        {
                            float originalRot = Main.rand.Next(0, 314) / 100;
                            for (int i = 0; i < 8; i++)
                            {
                                originalRot += (float)(Math.PI / 4f);
                                Vector2 velocity = originalRot.ToRotationVector2();
                                float velocityMult = Main.expertMode ? 8f : 5f;
                                velocity *= velocityMult;
                                Projectile.NewProjectile(p.Center.X, p.Center.Y, velocity.X, velocity.Y, 808, 10, 1f);
                            }
                            p.Kill();
                        }
                    }
                }
                //-------------------
                if (p.type == 809)
                {
                    p.owner = Main.myPlayer;
                    int emptyCounter = 0;
                    int enemy = 0;
                    for (int i = 0; i < 200; i++)
                    {
                        if (!Main.npc[i].active || Main.npc[i].life <= 0)
                        {
                            emptyCounter++;
                        }
                        if (emptyCounter > 8)
                        {
                            break;
                        }
                        if (Vector2.Distance(Main.npc[i].Center, p.Center) < Vector2.Distance(Main.npc[enemy].Center, p.Center))
                        {
                            enemy = i;
                        }
                    }
                    
                }
                //---------------
                if (p.type == 805)
                {
                    p.ai[5]++;
                    if (p.ai[5] > 5)
                    {
                        p.ai[5] = 0;
                        p.frame++;
                        if (p.frame > 3)
                        {
                            p.frame = 0;
                        }
                    }
                    if (p.ai[2] == 1)
                    {
                        if (p.ai[3] == 0)
                        {
                            p.ai[3]++;
                            p.circularAngle = p.ai[1];
                        }
                        float speed = (float)(Math.PI * 2) / 180;
                        float radius = 50;
                        p.circularAngle += speed;
                        p.Center = new Vector2((float)Math.Cos(p.circularAngle) * radius + Main.npc[(int)p.ai[0]].Center.X, (float)Math.Sin(p.circularAngle) * radius + Main.npc[(int)p.ai[0]].Center.Y);
                        if (Main.npc[(int)p.ai[0]].life <= 0 || Main.npc[(int)p.ai[0]].type != 579 || !Main.npc[(int)p.ai[0]].active)
                        {
                            p.Kill();
                        }
                    }
                    else
                    {
                        p.ai[6]++;
                        if (p.ai[6] > 120)
                        {
                            p.alpha += 15;
                            if (p.alpha >= 255)
                            {
                                p.Kill();
                            }
                        }
                    }
                }
                //-------------
                if (p.type == 801)
                {
                    if (p.ai[0] == 0f)
                    {
                        p.rotation += p.velocity.X * 0.02f;
                        p.velocity.Y += 0.0124f;
                        p.frame = (int)p.ai[1];
                    }
                    else if (p.ai[0] == 1)
                    {
                        p.frame = (int)p.ai[1];
                        if (p.ai[12] == 0f) p.ai[10] = Main.npc[(int)p.ai[2]].ai[14];
                        if (p.ai[10] == 0)
                        {
                            if (p.ai[7] == 0)
                            {
                                p.ai[7] = (float)((2 * Math.PI) / Main.rand.Next(70, 150));
                            }
                            float speed = p.ai[7];
                            float radius = 40;
                            p.circularAngle += speed;
                            p.Center =  new Vector2((float)Math.Cos(p.circularAngle) * radius + Main.npc[(int)p.ai[2]].Center.X, (float)Math.Sin(p.circularAngle) * radius + Main.npc[(int)p.ai[2]].Center.Y);
                            if (Main.npc[(int)p.ai[2]].life <= 0 || Main.npc[(int)p.ai[2]].type != 559 || !Main.npc[(int)p.ai[2]].active)
                            {
                                p.Kill();
                            }
                        }
                        else
                        {
                            p.ai[12] = 1;
                            if (p.ai[5] == 0)
                            {
                                p.tileCollide = true;
                                p.ai[5] = 1;
                                float num679 = 8f;
                                float num680 = Main.player[(int)p.ai[4]].Center.X - p.Center.X;
                                float num681 = Main.player[(int)p.ai[4]].Center.Y - p.Center.Y;
                                float num682 = (float)Math.Sqrt((double)(num680 * num680 + num681 * num681));
                                num682 = num679 / num682;
                                num680 *= num682;
                                num681 *= num682;
                                p.velocity.X = num680;
                                p.velocity.Y = num681;
                            }
                            p.rotation += p.velocity.X * 0.02f;
                            p.velocity.Y += 0.0124f;
                        }
                    }
                }
                //--------------------------
                if (p.type == 800)
                {
                    p.rotation = p.velocity.ToRotation() + (float)(Math.PI / 2);
                    for (int k = 0; k < 2; k++)
                    {
                        int du = Dust.NewDust(p.position, p.width, p.height, 6, 0f, 0f);
                        Main.dust[du].noGravity = true;
                    }
                }
                //--------------------------
                if (p.type >= 796 && p.type <= 799)
                {
                    if (p.type == 799)
                    {
                        for (int k = 0; k < 4; k++)
                        {
                            int du = Dust.NewDust(p.position, p.width, p.height, 6, 0f, 0f);
                            Main.dust[du].noGravity = true;
                        }
                        #region Homing
                        if (p.Center.X < Main.player[p.owner].Center.X)
                        {
                            p.velocity.X += 0.16f;
                            if (p.velocity.X > 8f)
                            {
                                p.velocity.X = 8f;
                            }
                        }
                        if (p.Center.X > Main.player[p.owner].Center.X)
                        {
                            p.velocity.X -= 0.16f;
                            if (p.velocity.X < -8f)
                            {
                                p.velocity.X = -8f;
                            }
                        }
                        if (p.Center.Y < Main.player[p.owner].Center.Y)
                        {
                            p.velocity.Y += 0.16f;
                            if (p.velocity.Y > 8f)
                            {
                                p.velocity.Y = 8f;
                            }
                        }
                        if (p.Center.Y > Main.player[p.owner].Center.Y)
                        {
                            p.velocity.Y -= 0.16f;
                            if (p.velocity.Y < -8f)
                            {
                                p.velocity.Y = -8f;
                            }
                        }
                        #endregion
                        p.rotation += 0.0821561f;
                        p.ai[3]++;
                        if (p.ai[3] > 120)
                        {
                            p.alpha += 5;
                            if (p.alpha >= 255)
                            {
                                Projectile.NewProjectile(p.Center.X, p.Center.Y, 0, -4, 798, 80, 1f, p.owner);
                                Projectile.NewProjectile(p.Center.X, p.Center.Y, 0, 4, 798, 80, 1f, p.owner);
                                p.Kill();
                            }
                        }
                    }
                    if (p.type == 798)
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            int du = Dust.NewDust(p.position, p.width, p.height, 6, 0f, 0f);
                            Main.dust[du].noGravity = true;
                        }
                        #region Homing
                        if (p.Center.X < Main.player[p.owner].Center.X)
                        {
                            p.velocity.X += 0.16f;
                            if (p.velocity.X > 8f)
                            {
                                p.velocity.X = 8f;
                            }
                        }
                        if (p.Center.X > Main.player[p.owner].Center.X)
                        {
                            p.velocity.X -= 0.16f;
                            if (p.velocity.X < -8f)
                            {
                                p.velocity.X = -8f;
                            }
                        }
                        if (p.Center.Y < Main.player[p.owner].Center.Y)
                        {
                            p.velocity.Y += 0.16f;
                            if (p.velocity.Y > 8f)
                            {
                                p.velocity.Y = 8f;
                            }
                        }
                        if (p.Center.Y > Main.player[p.owner].Center.Y)
                        {
                            p.velocity.Y -= 0.16f;
                            if (p.velocity.Y < -8f)
                            {
                                p.velocity.Y = -8f;
                            }
                        }
                        #endregion
                        p.rotation += 0.0821561f;
                        p.ai[3]++;
                        if (p.ai[3] > 60)
                        {
                            p.alpha += 5;
                            if (p.alpha >= 255)
                            {
                                int proj = Projectile.NewProjectile(p.Center.X, p.Center.Y, 4, 0, 797, 70, 1f, p.owner);
                                Main.projectile[proj].ai[5] = 1;
                                proj = Projectile.NewProjectile(p.Center.X, p.Center.Y, -4, 0, 797, 70, 1f, p.owner);
                                Main.projectile[proj].ai[5] = 1;
                                p.Kill();
                            }
                        }
                    }
                    if (p.type == 797 && p.ai[5] == 1)
                    {
                        for (int k = 0; k < 2; k++)
                        {
                            int du = Dust.NewDust(p.position, p.width, p.height, 6, 0f, 0f);
                            Main.dust[du].noGravity = true;
                        }
                        #region Homing
                        if (p.Center.X < Main.player[p.owner].Center.X)
                        {
                            p.velocity.X += 0.16f;
                            if (p.velocity.X > 8f)
                            {
                                p.velocity.X = 8f;
                            }
                        }
                        if (p.Center.X > Main.player[p.owner].Center.X)
                        {
                            p.velocity.X -= 0.16f;
                            if (p.velocity.X < -8f)
                            {
                                p.velocity.X = -8f;
                            }
                        }
                        if (p.Center.Y < Main.player[p.owner].Center.Y)
                        {
                            p.velocity.Y += 0.16f;
                            if (p.velocity.Y > 8f)
                            {
                                p.velocity.Y = 8f;
                            }
                        }
                        if (p.Center.Y > Main.player[p.owner].Center.Y)
                        {
                            p.velocity.Y -= 0.16f;
                            if (p.velocity.Y < -8f)
                            {
                                p.velocity.Y = -8f;
                            }
                        }
                        #endregion
                        p.rotation += 0.0821561f;
                        p.alpha += 5;
                        if (p.alpha >= 255)
                        {
                            Projectile.NewProjectile(p.Center.X, p.Center.Y, 0, -4, 796, 60, 1f, p.owner);
                            Projectile.NewProjectile(p.Center.X, p.Center.Y, 0, 4, 796, 60, 1f, p.owner);
                            p.Kill();
                        }
                    }
                    if (p.type == 796)
                    {
                        for (int k = 0; k < 1; k++)
                        {
                            int du = Dust.NewDust(p.position, p.width, p.height, 6, 0f, 0f);
                            Main.dust[du].noGravity = true;
                        }
                        #region Homing
                        if (p.Center.X < Main.player[p.owner].Center.X)
                        {
                            p.velocity.X += 0.16f;
                            if (p.velocity.X > 8f)
                            {
                                p.velocity.X = 8f;
                            }
                        }
                        if (p.Center.X > Main.player[p.owner].Center.X)
                        {
                            p.velocity.X -= 0.16f;
                            if (p.velocity.X < -8f)
                            {
                                p.velocity.X = -8f;
                            }
                        }
                        if (p.Center.Y < Main.player[p.owner].Center.Y)
                        {
                            p.velocity.Y += 0.16f;
                            if (p.velocity.Y > 8f)
                            {
                                p.velocity.Y = 8f;
                            }
                        }
                        if (p.Center.Y > Main.player[p.owner].Center.Y)
                        {
                            p.velocity.Y -= 0.16f;
                            if (p.velocity.Y < -8f)
                            {
                                p.velocity.Y = -8f;
                            }
                        }
                        #endregion
                        p.rotation += 0.0821561f;
                        p.ai[3]++;
                        if (p.ai[3] > 180)
                        {
                            p.alpha += 5;
                            if (p.alpha >= 255)
                            {
                                p.Kill();
                            }
                        }
                    }
                    //spinning flarework that explodes into fire
                    if (p.type == 797 && p.ai[5] == 0)
                    {
                        for (int k = 0; k < 2; k++)
                        {
                            int du = Dust.NewDust(p.position, p.width, p.height, 6, 0f, 0f);
                            Main.dust[du].noGravity = true;
                        }
                        #region homing
                        if (p.Center.X < Main.player[p.owner].Center.X)
                        {
                            p.velocity.X += 0.12f;
                            if (p.velocity.X > 5f)
                            {
                                p.velocity.X = 5f;
                            }
                        }
                        if (p.Center.X > Main.player[p.owner].Center.X)
                        {
                            p.velocity.X -= 0.12f;
                            if (p.velocity.X < -5f)
                            {
                                p.velocity.X = -5f;
                            }
                        }
                        if (p.Center.Y < Main.player[p.owner].Center.Y)
                        {
                            p.velocity.Y += 0.12f;
                            if (p.velocity.Y > 5f)
                            {
                                p.velocity.Y = 5f;
                            }
                        }
                        if (p.Center.Y > Main.player[p.owner].Center.Y)
                        {
                            p.velocity.Y -= 0.12f;
                            if (p.velocity.Y < -5f)
                            {
                                p.velocity.Y = -5f;
                            }
                        }
                        #endregion
                        p.rotation += 0.0821561f;
                        p.ai[3]++;
                        if (p.ai[3] > 120)
                        {
                            if (p.ai[3] % 7 == 0)
                            {
                                Vector2 vel = p.rotation.ToRotationVector2();
                                vel *= 6.5f;
                                int proj = Projectile.NewProjectile(p.Center.X, p.Center.Y, vel.X, vel.Y, 791, 58, 1f, Main.myPlayer, 0f, 1f);
                                Main.projectile[proj].friendly = false;
                                Main.projectile[proj].hostile = true;
                                Main.projectile[proj].tileCollide = false;
                            }
                            p.alpha += 5;
                            if (p.alpha >= 255)
                            {
                                p.Kill();
                            }
                        }
                    }
                }
                //-----------------------
                if (p.type == 795)
                {
                    if (p.ai[0] == 0)
                    {
                        p.ai[0]++;
                        p.Damage();
                        for (int i = 0; i < 15; i++)
                        {
                            Dust.NewDust(p.position, p.width, p.height, 152, Main.rand.Next(-4, 5), Main.rand.Next(-4, 5));
                        }
                    }
                    p.frameCounter++;
                    if (p.frameCounter >= 4)
                    {
                        p.frameCounter = 0;
                        p.frame++;
                        if (p.frame > 5)
                        {
                            p.Kill();
                        }
                    }
                }
                //---------------
                if (p.type == 794)
                {
                    p.rotation = p.velocity.ToRotation() - (float)(Math.PI / 2);
                }
                //--------------
                if (p.type == 793)
                {
                    p.rotation = p.velocity.ToRotation() + (float)(Math.PI / 2);
                    p.velocity.Y += 0.132f;
                }
                //------------
                if (p.type == 792)
                {
                    p.frameCounter++;
                    if (p.frameCounter >= 7)
                    {
                        p.frameCounter = 0;
                        p.frame++;
                        if (p.frame > 2)
                        {
                            p.frame = 0;
                        }
                    }
                    for (int i = 0; i < 2; i++)
                    {
                        int du = Dust.NewDust(p.position, p.width, p.height, 249, p.velocity.X * 0.8f, p.velocity.Y * 0.8f);
                        Main.dust[du].noGravity = true;
                    }
                    p.rotation = p.velocity.ToRotation() + (float)Math.PI;
                }
                //-----------
                if (p.type == 791)
                {
                    p.frameCounter++;
                    if (p.frameCounter >= 7)
                    {
                        p.frameCounter = 0;
                        p.frame++;
                        if (p.frame > 2)
                        {
                            p.frame = 0;
                        }
                    }
                    for (int i = 0; i < 4 - ((1f - p.scale) * 15); i++)
                    {
                        int du = Dust.NewDust(p.position, p.width, p.height, 6, p.velocity.X * 0.5f, p.velocity.Y * 0.5f);
                        Main.dust[du].noGravity = true;
                    }
                    p.rotation = p.velocity.ToRotation() + (float)Math.PI;
                    if (p.ai[1] == 0f && p.ai[2] == 0f)
                    {
                        p.ai[0]++;
                        if (p.ai[0] > 60)
                        {
                            for (int k = 0; k < 2; k++)
                            {
                                int randAngle = Main.rand.Next(0, 361);
                                Vector2 position = new Vector2(
                                    (float)Math.Cos(MathHelper.ToRadians(randAngle)) * 15 + p.position.X,
                                    (float)Math.Sin(MathHelper.ToRadians(randAngle)) * 15 + p.position.Y
                                    );
                                Vector2 velocity = p.position - position;
                                velocity.Normalize();
                                velocity *= 1.5f;
                                int newDust = Dust.NewDust(position, 38, 38, 6, -velocity.X, -velocity.Y, 50 + Main.rand.Next(0, 151));
                                Main.dust[newDust].noGravity = true;
                                Main.dust[newDust].velocity = velocity;
                            }
                            p.velocity *= 0.95f;
                        }
                        if (p.ai[0] > 120)
                        {
                            p.Kill();
                        }
                    }
                    else
                    {
                        if (p.ai[2] == 0f)
                            p.scale = 0.75f;
                    }
                }
                //-----------
                if (p.type == 790)
                {
                    for (int j = 0; j < 200; j++)
                    {
                        if (Vector2.Distance(Main.npc[j].Center, p.Center) < 550f && Vector2.Distance(Main.npc[j].Center, p.Center) > 30f)
                        {
                            if (!Main.npc[j].boss && Main.npc[j].knockBackResist != 0f)
                            {
                                float sp = 6f - (Vector2.Distance(Main.npc[j].Center, p.position) / 100);
                                Vector2 pos = p.position - Main.npc[j].Center;
                                float mag = (float)Math.Sqrt(Math.Pow(pos.X, 2) + Math.Pow(pos.Y, 2));
                                if (mag > sp)
                                {
                                    pos *= sp / mag;
                                }
                                Main.npc[j].velocity += pos *= 0.1f;
                            }
                        }
                    }
                    p.frameCounter++;
                    if (p.frameCounter >= 6)
                    {
                        p.frameCounter = 0;
                        p.frame++;
                        if (p.frame > 2)
                        {
                            p.frame = 0;
                        }
                    }
                    if (p.ai[0] == 0)
                    {
                        p.alpha = 255;
                        p.ai[0] = 1f;
                        p.ai[1] = Main.rand.Next(2) == 0 ? -0.04352f : 0.04352f; 
                    }
                    p.rotation += p.ai[1];
                    p.ai[0]++;
                    if (p.alpha > 0 && p.ai[0] < 150)
                    {
                        p.alpha -= 10;
                        if (p.alpha < 0)
                        {
                            p.alpha = 0;
                        }
                    }
                    if (p.ai[0] > 345)
                    {
                        p.alpha++;
                        if (p.alpha > 255)
                        {
                            p.Kill();
                        }
                    }
                    for (int i = 0; i < 4 + (int)(p.ai[0] / 60); i++)
                    {
                        int radius = i * 10;
                        for (int d = 0; d < 2; d++)
                        {
                            if (Main.rand.Next(0, 10 - (int)(p.ai[0] / 120)) == 0)
                            {
                                int randAngle = Main.rand.Next(0, 361);
                                Vector2 position = new Vector2(
                                    (float)Math.Cos(MathHelper.ToRadians(randAngle)) * radius + p.position.X,
                                    (float)Math.Sin(MathHelper.ToRadians(randAngle)) * radius + p.position.Y
                                    );
                                Vector2 velocity = p.position - position;
                                velocity.Normalize();
                                velocity *= 4 + (radius / 45);
                                int newDust = Dust.NewDust(position, 38, 38, 249, -velocity.X, -velocity.Y, 50 + Main.rand.Next(0, 151));
                                Main.dust[newDust].noGravity = true;
                                Main.dust[newDust].velocity = velocity;
                            }
                        }
                    }
                }
                //---------------
                if (p.type == 789)
                {
                    p.alpha += 4;
                    if (p.alpha > 255)
                    {
                        p.Kill();
                    }
                    Lighting.AddLight(p.Center, 0.0255f, 0.0153f, 0);
                }
                if (p.type == 788)
                {
                    p.rotation = p.velocity.ToRotation() + (float)(Math.PI / 2);
                    p.velocity.Y += 0.145f;
                    p.ai[0] += Main.rand.Next(50, 150) / 100;
                    if (p.ai[0] >= 3)
                    {
                        p.ai[0] = 0;
                        Projectile.NewProjectile(p.Center.X, p.Center.Y, 0f, 0f, 789, 10, 1f, Main.myPlayer);
                    }
                    Lighting.AddLight(p.Center, 0.0510f, 0.0306f, 0);
                }
                if (p.type == 787)
                {
                    p.rotation += p.velocity.X * 0.05f;
                }
                //-------------
                if (p.type == 785 || p.type == 786)
                {
                    if (p.ai[1] == 0f && !Collision.SolidCollision(p.position, p.width, p.height))
                    {
                        p.ai[1] = 1f;
                        p.netUpdate = true;
                    }
                    if (p.ai[1] != 0f)
                    {
                        p.tileCollide = true;
                    }
                    if (p.soundDelay == 0)
                    {
                        p.soundDelay = 20 + Main.rand.Next(40);
                        Main.PlaySound(2, (int)p.position.X, (int)p.position.Y, 9);
                    }
                    if (p.localAI[0] == 0f)
                    {
                        p.localAI[0] = 1f;
                    }
                    p.alpha += (int)(25f * p.localAI[0]);
                    if (p.alpha > 200)
                    {
                        p.alpha = 200;
                        p.localAI[0] = -1f;
                    }
                    if (p.alpha < 0)
                    {
                        p.alpha = 0;
                        p.localAI[0] = 1f;
                    }
                    if (p.type != 786) p.rotation += (Math.Abs(p.velocity.X) + Math.Abs(p.velocity.Y)) * 0.01f * (float)p.direction;
                    else p.rotation = p.velocity.ToRotation() + (float)(Math.PI / 2);
                    p.light = 0.9f;
                    if (Main.rand.Next(10) == 0)
                    {                                       
                        Dust.NewDust(p.position, p.width, p.height, 152, p.velocity.X * 0.5f, p.velocity.Y * 0.5f, 150, default(Color), 1.2f);
                    }
                    if (p.type != 786)
                    {
                        if (Main.rand.Next(20) == 0)
                        {
                            Gore.NewGore(p.position, new Vector2(p.velocity.X * 0.2f, p.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f);
                        }
                    }
                }
                //------------
                if (p.type == 784)
                {
                    p.rotation += p.velocity.X * 0.05f;
                    p.velocity.Y += 0.135f;
                    try
                    {
                        int num223 = (int)(p.position.X / 16f) - 1;
                        int num224 = (int)((p.position.X + (float)p.width) / 16f) + 2;
                        int num225 = (int)(p.position.Y / 16f) - 1;
                        int num226 = (int)((p.position.Y + (float)p.height) / 16f) + 2;
                        if (num223 < 0)
                        {
                            num223 = 0;
                        }
                        if (num224 > Main.maxTilesX)
                        {
                            num224 = Main.maxTilesX;
                        }
                        if (num225 < 0)
                        {
                            num225 = 0;
                        }
                        if (num226 > Main.maxTilesY)
                        {
                            num226 = Main.maxTilesY;
                        }
                        for (int num227 = num223; num227 < num224; num227++)
                        {
                            for (int num228 = num225; num228 < num226; num228++)
                            {
                                if (Main.tile[num227, num228] != null && Main.tile[num227, num228].nactive() && (Main.tileSolid[(int)Main.tile[num227, num228].type] || (Main.tileSolidTop[(int)Main.tile[num227, num228].type] && Main.tile[num227, num228].frameY == 0)))
                                {
                                    Vector2 vector19;
                                    vector19.X = (float)(num227 * 16);
                                    vector19.Y = (float)(num228 * 16);
                                    if (p.position.X + (float)p.width - 4f > vector19.X && p.position.X + 4f < vector19.X + 16f && p.position.Y + (float)p.height - 4f > vector19.Y && p.position.Y + 4f < vector19.Y + 16f)
                                    {
                                        p.velocity.X = 0f;
                                        p.velocity.Y = 0f;
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                //------------
                if (p.type == 783)
                {
                    p.rotation += p.velocity.X * 0.05f;
                    p.velocity.Y += 0.135f;
                }
                //------------
                if (p.type == 782)
                {
                    p.rotation = p.velocity.ToRotation() + (float)(Math.PI / 2);
                }
                //------------
                if (p.type == 777)
                {
                    if (p.ai[0] == 0)
                    {
                        p.ai[0]++;
                        p.ai[1] = Main.rand.Next(-6, 7) / 100;
                    }
                    p.rotation += p.ai[1];
                    p.velocity.Y += 0.145f;
                }
                //------------
                else if (p.type == 779)
                {
                    if (Main.player[Main.myPlayer].birdnana)
                    {//
                        p.timeLeft = 2;
                    }
                    p.friendly = true;
                    float num531 = 6f;
                    if (p.ai[0] == 1f)
                    {
                        num531 = 10f;
                    }
                    Vector2 vector38 = new Vector2(p.position.X + (float)p.width * 0.5f, p.position.Y + (float)p.height * 0.5f);
                    float num532 = Main.player[p.owner].Center.X - vector38.X + (20f * Main.player[p.owner].direction);
                    float num533 = Main.player[p.owner].Center.Y - vector38.Y;
                    float num534 = (float)Math.Sqrt((double)(num532 * num532 + num533 * num533));
                    if (num534 < 100f && p.ai[0] == 1f && !Collision.SolidCollision(p.position, p.width, p.height))
                    {
                        p.ai[0] = 0f;
                    }
                    if (num534 > 2000f)
                    {
                        p.position.X = Main.player[p.owner].Center.X - (float)(p.width / 2);
                        p.position.Y = Main.player[p.owner].Center.Y - (float)(p.width / 2);
                    }
                    if (num534 > 70f)
                    {
                        num534 = num531 / num534;
                        num532 *= num534;
                        num533 *= num534;
                        p.velocity.X = (p.velocity.X * 20f + num532) / 21f;
                        p.velocity.Y = (p.velocity.Y * 20f + num533) / 21f;
                    }
                    else
                    {
                        if (p.velocity.X == 0f && p.velocity.Y == 0f)
                        {
                            p.velocity.X = -0.15f;
                            p.velocity.Y = -0.05f;
                        }
                        p.velocity *= 1.01f;
                    }
                    p.friendly = false;
                    p.rotation = p.velocity.X * 0.05f;
                    p.frameCounter++;
                    if (p.frameCounter >= 7)
                    {
                        p.frameCounter = 0;
                        p.frame++;
                    }
                    if (p.frame > 3)
                    {
                        p.frame = 0;
                    }
                    if ((double)Math.Abs(p.velocity.X) > 0.15)
                    {
                        p.spriteDirection = p.direction;
                    }
                }
                //------------
                if (p.type == 772)
                {
                    p.rotation = p.velocity.ToRotation() + (float)(Math.PI / 2);
                    p.velocity.Y += 0.145f;
                    p.ai[0] += Main.rand.Next(50, 150) / 100;
                    if (p.ai[0] >= 15)
                    {
                        p.ai[0] = 0;
                        Projectile.NewProjectile(p.Center.X, p.Center.Y, 0f, 0f, 777, 10, 1f, Main.myPlayer);
                    }
                }
            }
        }