Terraria.Projectile.AI_075 C# (CSharp) Method

AI_075() private method

private AI_075 ( ) : void
return void
        private void AI_075()
        {
            Player player = Main.player[owner];
            float num1 = 1.570796f;
            Vector2 vector2_1 = player.RotatedRelativePoint(player.MountedCenter, true);
            if (type == 439)
            {
                ++ai[0];
                int num2 = 0;
                if (ai[0] >= 40.0)
                    ++num2;
                if (ai[0] >= 80.0)
                    ++num2;
                if (ai[0] >= 120.0)
                    ++num2;
                int num3 = 24;
                int num4 = 6;
                ++ai[1];
                bool flag = false;
                if (ai[1] >= (double)(num3 - num4 * num2))
                {
                    ai[1] = 0.0f;
                    flag = true;
                }
                frameCounter += 1 + num2;
                if (frameCounter >= 4)
                {
                    frameCounter = 0;
                    ++frame;
                    if (frame >= 6)
                        frame = 0;
                }
                if (soundDelay <= 0)
                {
                    soundDelay = num3 - num4 * num2;
                    if (ai[0] != 1.0)
                        Main.PlaySound(2, (int)position.X, (int)position.Y, 91);
                }
                if (ai[1] == 1.0 && ai[0] != 1.0)
                {
                    Vector2 vector2_2 = Center + Utils.RotatedBy(Vector2.UnitX * 24f, rotation - 1.57079637050629, new Vector2());
                    for (int index1 = 0; index1 < 2; ++index1)
                    {
                        int index2 = Dust.NewDust(vector2_2 - Vector2.One * 8f, 16, 16, 135, velocity.X / 2f, velocity.Y / 2f, 100, new Color(), 1f);
                        Main.dust[index2].velocity *= 0.66f;
                        Main.dust[index2].noGravity = true;
                        Main.dust[index2].scale = 1.4f;
                    }
                }
                if (flag && Main.myPlayer == owner)
                {
                    if (player.channel && player.CheckMana(player.inventory[player.selectedItem].mana, true, false) && !player.noItems)
                    {
                        float num5 = player.inventory[player.selectedItem].shootSpeed * scale;
                        Vector2 vector2_2 = vector2_1;
                        Vector2 vector2_3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - vector2_2;
                        if (player.gravDir == -1.0)
                            vector2_3.Y = (Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector2_2.Y;
                        Vector2 vector2_4 = Vector2.Normalize(vector2_3);
                        if (float.IsNaN(vector2_4.X) || float.IsNaN(vector2_4.Y))
                            vector2_4 = -Vector2.UnitY;
                        vector2_4 *= num5;
                        if (vector2_4.X != velocity.X || vector2_4.Y != velocity.Y)
                            netUpdate = true;
                        velocity = vector2_4;
                        int Type = 440;
                        float num6 = 14f;
                        int num7 = 7;
                        for (int index = 0; index < 2; ++index)
                        {
                            Vector2 vector2_5 = Center + new Vector2(Main.rand.Next(-num7, num7 + 1), Main.rand.Next(-num7, num7 + 1));
                            Vector2 spinningpoint = Vector2.Normalize(velocity) * num6;
                            spinningpoint = Utils.RotatedBy(spinningpoint, Main.rand.NextDouble() * 0.196349546313286 - 0.0981747731566429, new Vector2());
                            if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y))
                                spinningpoint = -Vector2.UnitY;
                            NewProjectile(vector2_5.X, vector2_5.Y, spinningpoint.X, spinningpoint.Y, Type, damage, knockBack, owner, 0.0f, 0.0f);
                        }
                    }
                    else
                        Kill();
                }
            }
            if (type == 445)
            {
                ++localAI[0];
                if (localAI[0] >= 60.0)
                    localAI[0] = 0.0f;
                if (Vector2.Distance(vector2_1, Center) >= 5.0)
                {
                    float num2 = localAI[0] / 60f;
                    if (num2 > 0.5)
                        num2 = 1f - num2;
                    Vector3 vector3 = Vector3.Lerp(new Vector3(0.0f, 1f, 0.7f), new Vector3(0.0f, 0.7f, 1f), (float)(1.0 - num2 * 2.0)) * 0.5f;
                    if (Vector2.Distance(vector2_1, Center) >= 30.0)
                    {
                        Vector2 vector2_2 = Center - vector2_1;
                        vector2_2.Normalize();
                        Vector2 vector2_3 = vector2_2 * (Vector2.Distance(vector2_1, Center) - 30f);
                        DelegateMethods.v3_1 = vector3 * 0.8f;
                        Utils.PlotTileLine(Center - vector2_3, Center, 8f, new Utils.PerLinePoint(DelegateMethods.CastLightOpen));
                    }
                    Lighting.AddLight((int)Center.X / 16, (int)Center.Y / 16, vector3.X, vector3.Y, vector3.Z);
                }
                if (Main.myPlayer == owner)
                {
                    if (localAI[1] > 0.0)
                        --localAI[1];
                    if (!player.channel || player.noItems)
                        Kill();
                    else if (localAI[1] == 0.0)
                    {
                        Vector2 vector2_2 = vector2_1;
                        Vector2 vector2_3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - vector2_2;
                        if (player.gravDir == -1.0)
                            vector2_3.Y = (Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector2_2.Y;
                        if (Main.tile[Player.tileTargetX, Player.tileTargetY].active())
                        {
                            vector2_3 = new Vector2(Player.tileTargetX, Player.tileTargetY) * 16f + Vector2.One * 8f - vector2_2;
                            localAI[1] = 2f;
                        }
                        Vector2 vector2_4 = Vector2.Lerp(vector2_3, velocity, 0.7f);
                        if (float.IsNaN(vector2_4.X) || float.IsNaN(vector2_4.Y))
                            vector2_4 = -Vector2.UnitY;
                        float num2 = 30f;
                        if (vector2_4.Length() < num2)
                            vector2_4 = Vector2.Normalize(vector2_4) * num2;
                        int num3 = player.inventory[player.selectedItem].tileBoost;
                        int num4 = -Player.tileRangeX - num3 + 1;
                        int num5 = Player.tileRangeX + num3 - 1;
                        int num6 = -Player.tileRangeY - num3;
                        int num7 = Player.tileRangeY + num3 - 1;
                        int num8 = 12;
                        bool flag = false;
                        if (vector2_4.X < (num4 * 16 - num8))
                            flag = true;
                        if (vector2_4.Y < (num6 * 16 - num8))
                            flag = true;
                        if (vector2_4.X > (num5 * 16 + num8))
                            flag = true;
                        if (vector2_4.Y > (num7 * 16 + num8))
                            flag = true;
                        if (flag)
                        {
                            Vector2 vector2_5 = Vector2.Normalize(vector2_4);
                            float num9 = -1f;
                            if (vector2_5.X < 0.0 && ((num4 * 16 - num8) / vector2_5.X < num9 || num9 == -1.0))
                                num9 = (num4 * 16 - num8) / vector2_5.X;
                            if (vector2_5.X > 0.0 && ((num5 * 16 + num8) / vector2_5.X < num9 || num9 == -1.0))
                                num9 = (num5 * 16 + num8) / vector2_5.X;
                            if (vector2_5.Y < 0.0 && ((num6 * 16 - num8) / vector2_5.Y < num9 || num9 == -1.0))
                                num9 = (num6 * 16 - num8) / vector2_5.Y;
                            if (vector2_5.Y > 0.0 && ((num7 * 16 + num8) / vector2_5.Y < num9 || num9 == -1.0))
                                num9 = (num7 * 16 + num8) / vector2_5.Y;
                            vector2_4 = vector2_5 * num9;
                        }
                        if (vector2_4.X != velocity.X || vector2_4.Y != velocity.Y)
                            netUpdate = true;
                        velocity = vector2_4;
                    }
                }
            }
            if (type == 460)
            {
                ++ai[0];
                int num2 = 0;
                if (ai[0] >= 60.0)
                    ++num2;
                if (ai[0] >= 180.0)
                    ++num2;
                bool flag1 = false;
                if (ai[0] == 60.0 || ai[0] == 180.0 || ai[0] > 180.0 && ai[0] % 20.0 == 0.0)
                    flag1 = true;
                bool flag2 = ai[0] >= 180.0;
                int num3 = 10;
                if (!flag2)
                    ++ai[1];
                bool flag3 = false;
                if (flag2 && ai[0] % 20.0 == 0.0)
                    flag3 = true;
                if (ai[1] >= num3 && !flag2)
                {
                    ai[1] = 0.0f;
                    flag3 = true;
                    if (!flag2)
                    {
                        float num4 = player.inventory[player.selectedItem].shootSpeed * scale;
                        Vector2 vector2_2 = vector2_1;
                        Vector2 vector2_3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - vector2_2;
                        if (player.gravDir == -1.0)
                            vector2_3.Y = (Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector2_2.Y;
                        Vector2 vector2_4 = Vector2.Normalize(vector2_3);
                        if (float.IsNaN(vector2_4.X) || float.IsNaN(vector2_4.Y))
                            vector2_4 = -Vector2.UnitY;
                        vector2_4 *= num4;
                        if (vector2_4.X != velocity.X || vector2_4.Y != velocity.Y)
                            netUpdate = true;
                        velocity = vector2_4;
                    }
                }
                if (soundDelay <= 0 && !flag2)
                {
                    soundDelay = num3 - num2;
                    soundDelay *= 2;
                    if (ai[0] != 1.0)
                        Main.PlaySound(2, (int)position.X, (int)position.Y, 15);
                }
                if (ai[0] > 10.0 && !flag2)
                {
                    Vector2 vector2_2 = Center + Utils.RotatedBy(Vector2.UnitX * 18f, rotation - 1.57079637050629, new Vector2());
                    for (int index1 = 0; index1 < num2 + 1; ++index1)
                    {
                        int Type = 226;
                        float num4 = 0.4f;
                        if (index1 % 2 == 1)
                        {
                            Type = 226;
                            num4 = 0.65f;
                        }
                        Vector2 vector2_3 = vector2_2 + Utils.ToRotationVector2((float)Main.rand.NextDouble() * 6.283185f) * (12f - (num2 * 2));
                        int index2 = Dust.NewDust(vector2_3 - Vector2.One * 8f, 16, 16, Type, velocity.X / 2f, velocity.Y / 2f, 0, new Color(), 1f);
                        Main.dust[index2].velocity = Vector2.Normalize(vector2_2 - vector2_3) * 1.5f * (float)(10.0 - num2 * 2.0) / 10f;
                        Main.dust[index2].noGravity = true;
                        Main.dust[index2].scale = num4;
                        Main.dust[index2].customData = player;
                    }
                }
                if (flag3 && Main.myPlayer == owner)
                {
                    bool flag4 = !flag1 || player.CheckMana(player.inventory[player.selectedItem].mana, true, false);
                    if (player.channel && flag4 && !player.noItems)
                    {
                        if (ai[0] == 180.0)
                        {
                            Vector2 center = Center;
                            Vector2 vector2_2 = Vector2.Normalize(velocity);
                            if (float.IsNaN(vector2_2.X) || float.IsNaN(vector2_2.Y))
                                vector2_2 = -Vector2.UnitY;
                            int Damage = (int)(damage * 3.0);
                            ai[1] = NewProjectile(center.X, center.Y, vector2_2.X, vector2_2.Y, 461, Damage, knockBack, owner, 0.0f, whoAmI);
                            netUpdate = true;
                        }
                        else if (flag2)
                        {
                            Projectile projectile = Main.projectile[(int)ai[1]];
                            if (!projectile.active || projectile.type != 461)
                            {
                                Kill();
                                return;
                            }
                        }
                    }
                    else
                    {
                        if (!flag2)
                        {
                            int Type = 459;
                            float num4 = 10f;
                            Vector2 center = Center;
                            Vector2 vector2_2 = Vector2.Normalize(velocity) * num4;
                            if (float.IsNaN(vector2_2.X) || float.IsNaN(vector2_2.Y))
                                vector2_2 = -Vector2.UnitY;
                            float ai1 = (float)(0.699999988079071 + num2 * 0.300000011920929);
                            int Damage = ai1 < 1.0 ? damage : (int)(damage * 2.0);
                            NewProjectile(center.X, center.Y, vector2_2.X, vector2_2.Y, Type, Damage, knockBack, owner, 0.0f, ai1);
                        }
                        Kill();
                    }
                }
            }
            if (type == 633)
            {
                float num2 = 30f;
                if (ai[0] > 90.0)
                    num2 = 15f;
                if (ai[0] > 120.0)
                    num2 = 5f;
                damage = (int)(player.inventory[player.selectedItem].damage * player.magicDamage);
                ++ai[0];
                ++ai[1];
                bool flag1 = false;
                if (ai[0] % num2 == 0.0)
                    flag1 = true;
                int num3 = 10;
                bool flag2 = false;
                if (ai[0] % num2 == 0.0)
                    flag2 = true;
                if (ai[1] >= 1.0)
                {
                    ai[1] = 0.0f;
                    flag2 = true;
                    if (Main.myPlayer == owner)
                    {
                        float num4 = player.inventory[player.selectedItem].shootSpeed * scale;
                        Vector2 vector2_2 = vector2_1;
                        Vector2 vector2_3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - vector2_2;
                        if (player.gravDir == -1.0)
                            vector2_3.Y = (Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector2_2.Y;
                        Vector2 vector2_4 = Vector2.Normalize(vector2_3);
                        if (float.IsNaN(vector2_4.X) || float.IsNaN(vector2_4.Y))
                            vector2_4 = -Vector2.UnitY;
                        vector2_4 = Vector2.Normalize(Vector2.Lerp(vector2_4, Vector2.Normalize(velocity), 0.92f));
                        vector2_4 *= num4;
                        if (vector2_4.X != velocity.X || vector2_4.Y != velocity.Y)
                            netUpdate = true;
                        velocity = vector2_4;
                    }
                }
                ++frameCounter;
                if (frameCounter >= (ai[0] < 120.0 ? 4 : 1))
                {
                    frameCounter = 0;
                    if (++frame >= 5)
                        frame = 0;
                }
                if (soundDelay <= 0)
                {
                    soundDelay = num3;
                    soundDelay *= 2;
                    if (ai[0] != 1.0)
                        Main.PlaySound(2, (int)position.X, (int)position.Y, 15);
                }
                if (flag2 && Main.myPlayer == owner)
                {
                    bool flag3 = !flag1 || player.CheckMana(player.inventory[player.selectedItem].mana, true, false);
                    if (player.channel && flag3 && !player.noItems)
                    {
                        if (ai[0] == 1.0)
                        {
                            Vector2 center = Center;
                            Vector2 vector2_2 = Vector2.Normalize(velocity);
                            if (float.IsNaN(vector2_2.X) || float.IsNaN(vector2_2.Y))
                                vector2_2 = -Vector2.UnitY;
                            int Damage = damage;
                            for (int index = 0; index < 6; ++index)
                                NewProjectile(center.X, center.Y, vector2_2.X, vector2_2.Y, 632, Damage, knockBack, owner, index, whoAmI);
                            netUpdate = true;
                        }
                    }
                    else
                        Kill();
                }
            }
            if (type == 595)
            {
                num1 = 0.0f;
                if (spriteDirection == -1)
                    num1 = 3.141593f;
                if (++frame >= Main.projFrames[type])
                    frame = 0;
                --soundDelay;
                if (soundDelay <= 0)
                {
                    Main.PlaySound(2, (int)Center.X, (int)Center.Y, 1);
                    soundDelay = 12;
                }
                if (Main.myPlayer == owner)
                {
                    if (player.channel && !player.noItems)
                    {
                        float num2 = 1f;
                        if (player.inventory[player.selectedItem].shoot == type)
                            num2 = player.inventory[player.selectedItem].shootSpeed * scale;
                        Vector2 vec = Main.MouseWorld - vector2_1;
                        vec.Normalize();
                        if (Utils.HasNaNs(vec))
                            vec = Vector2.UnitX * player.direction;
                        vec *= num2;
                        if ((double)vec.X != velocity.X || (double)vec.Y != velocity.Y)
                            netUpdate = true;
                        velocity = vec;
                    }
                    else
                        Kill();
                }
                Vector2 position = Center + velocity * 3f;
                Lighting.AddLight(position, 0.8f, 0.8f, 0.8f);
                if (Main.rand.Next(3) == 0)
                {
                    int index = Dust.NewDust(position - Size / 2f, width, height, 63, velocity.X, velocity.Y, 100, new Color(), 2f);
                    Main.dust[index].noGravity = true;
                    Main.dust[index].position -= velocity;
                }
            }
            if (type == 600)
            {
                if (ai[0] == 0.0)
                {
                    if (ai[1] != 0.0)
                        Main.PlaySound(2, (int)position.X, (int)position.Y, 114);
                    else
                        Main.PlaySound(2, (int)position.X, (int)position.Y, 115);
                }
                ++ai[0];
                if (Main.myPlayer == owner && ai[0] == 1.0)
                {
                    float num2 = player.inventory[player.selectedItem].shootSpeed * scale;
                    Vector2 vector2_2 = vector2_1;
                    Vector2 vector2_3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - vector2_2;
                    if (player.gravDir == -1.0)
                        vector2_3.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector2_2.Y;
                    Vector2 vector2_4 = Vector2.Normalize(vector2_3);
                    if (float.IsNaN(vector2_4.X) || float.IsNaN(vector2_4.Y))
                        vector2_4 = -Vector2.UnitY;
                    vector2_4 *= num2;
                    if (vector2_4.X != velocity.X || vector2_4.Y != velocity.Y)
                        netUpdate = true;
                    velocity = vector2_4;
                    int Type = 601;
                    float num3 = 3f;
                    Vector2 center = Center;
                    Vector2 vector2_5 = Vector2.Normalize(velocity) * num3;
                    if (float.IsNaN(vector2_5.X) || float.IsNaN(vector2_5.Y))
                        vector2_5 = -Vector2.UnitY;
                    NewProjectile(center.X, center.Y, vector2_5.X, vector2_5.Y, Type, damage, knockBack, owner, ai[1], 0.0f);
                }
                if (ai[0] >= 30.0)
                    Kill();
            }
            if (type == 611)
            {
                if (localAI[1] > 0.0)
                    --localAI[1];
                alpha -= 42;
                if (alpha < 0)
                    alpha = 0;
                if (localAI[0] == 0.0)
                    localAI[0] = Utils.ToRotation(velocity);
                float num2 = Utils.ToRotationVector2(localAI[0]).X >= 0.0 ? 1f : -1f;
                if (ai[1] <= 0.0)
                    num2 *= -1f;
                Vector2 spinningpoint = Utils.ToRotationVector2(num2 * (float)(ai[0] / 30.0 * 6.28318548202515 - 1.57079637050629));
                spinningpoint.Y *= (float)Math.Sin(ai[1]);
                if (ai[1] <= 0.0)
                    spinningpoint.Y *= -1f;
                Vector2 vector2_2 = Utils.RotatedBy(spinningpoint, localAI[0], new Vector2());
                ++ai[0];
                if (ai[0] < 30.0)
                {
                    Projectile projectile = this;
                    Vector2 vector2_3 = projectile.velocity + 48f * vector2_2;
                    projectile.velocity = vector2_3;
                }
                else
                    Kill();
            }
            if (type == 615)
            {
                num1 = 0.0f;
                if (spriteDirection == -1)
                    num1 = 3.141593f;
                ++ai[0];
                int num2 = 0;
                if (ai[0] >= 40.0)
                    ++num2;
                if (ai[0] >= 80.0)
                    ++num2;
                if (ai[0] >= 120.0)
                    ++num2;
                int num3 = 5;
                int num4 = 0;
                --ai[1];
                bool flag = false;
                int num5 = -1;
                if (ai[1] <= 0.0)
                {
                    ai[1] = (float)(num3 - num4 * num2);
                    flag = true;
                    if ((int)ai[0] / (num3 - num4 * num2) % 7 == 0)
                        num5 = 0;
                }
                frameCounter += 1 + num2;
                if (frameCounter >= 4)
                {
                    frameCounter = 0;
                    ++frame;
                    if (frame >= Main.projFrames[type])
                        frame = 0;
                }
                if (soundDelay <= 0)
                {
                    soundDelay = num3 - num4 * num2;
                    if (ai[0] != 1.0)
                        Main.PlaySound(2, (int)position.X, (int)position.Y, 36);
                }
                if (flag && Main.myPlayer == owner)
                {
                    bool canShoot = player.channel && player.HasAmmo(player.inventory[player.selectedItem], true) && !player.noItems;
                    int shoot = 14;
                    float speed = 14f;
                    int Damage = player.inventory[player.selectedItem].damage;
                    float KnockBack = player.inventory[player.selectedItem].knockBack;
                    if (canShoot)
                    {
                        player.PickAmmo(player.inventory[player.selectedItem], ref shoot, ref speed, ref canShoot, ref Damage, ref KnockBack, false);
                        float num6 = player.inventory[player.selectedItem].shootSpeed * scale;
                        Vector2 vector2_2 = vector2_1;
                        Vector2 vector2_3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - vector2_2;
                        if (player.gravDir == -1.0)
                            vector2_3.Y = (Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector2_2.Y;
                        Vector2 spinningpoint1 = Vector2.Normalize(vector2_3);
                        if (float.IsNaN(spinningpoint1.X) || float.IsNaN(spinningpoint1.Y))
                            spinningpoint1 = -Vector2.UnitY;
                        spinningpoint1 *= num6;
                        spinningpoint1 = Utils.RotatedBy(spinningpoint1, Main.rand.NextDouble() * 0.130899697542191 - 0.0654498487710953, new Vector2());
                        if ((double)spinningpoint1.X != velocity.X || (double)spinningpoint1.Y != velocity.Y)
                            netUpdate = true;
                        velocity = spinningpoint1;
                        for (int index = 0; index < 1; ++index)
                        {
                            Vector2 spinningpoint2 = Vector2.Normalize(velocity) * speed;
                            spinningpoint2 = Utils.RotatedBy(spinningpoint2, Main.rand.NextDouble() * 0.196349546313286 - 0.0981747731566429, new Vector2());
                            if (float.IsNaN(spinningpoint2.X) || float.IsNaN(spinningpoint2.Y))
                                spinningpoint2 = -Vector2.UnitY;
                            NewProjectile(vector2_2.X, vector2_2.Y, spinningpoint2.X, spinningpoint2.Y, shoot, Damage, KnockBack, owner, 0.0f, 0.0f);
                        }
                        if (num5 == 0)
                        {
                            shoot = 616;
                            float num7 = 8f;
                            for (int index = 0; index < 1; ++index)
                            {
                                Vector2 spinningpoint2 = Vector2.Normalize(velocity) * num7;
                                spinningpoint2 = Utils.RotatedBy(spinningpoint2, Main.rand.NextDouble() * 0.392699092626572 - 0.196349546313286, new Vector2());
                                if (float.IsNaN(spinningpoint2.X) || float.IsNaN(spinningpoint2.Y))
                                    spinningpoint2 = -Vector2.UnitY;
                                NewProjectile(vector2_2.X, vector2_2.Y, spinningpoint2.X, spinningpoint2.Y, shoot, Damage + 20, KnockBack * 1.25f, owner, 0.0f, 0.0f);
                            }
                        }
                    }
                    else
                        Kill();
                }
            }
            if (type == 630)
            {
                num1 = 0.0f;
                if (spriteDirection == -1)
                    num1 = 3.141593f;
                ++ai[0];
                int num2 = 0;
                if (ai[0] >= 40.0)
                    ++num2;
                if (ai[0] >= 80.0)
                    ++num2;
                if (ai[0] >= 120.0)
                    ++num2;
                int num3 = 24;
                int num4 = 2;
                --ai[1];
                bool flag = false;
                if (ai[1] <= 0.0)
                {
                    ai[1] = (num3 - num4 * num2);
                    flag = true;
                    int num5 = (int)ai[0] / (num3 - num4 * num2);
                }
                bool canShoot = player.channel && player.HasAmmo(player.inventory[player.selectedItem], true) && !player.noItems;
                if (localAI[0] > 0.0)
                    --localAI[0];
                if (soundDelay <= 0 && canShoot)
                {
                    soundDelay = num3 - num4 * num2;
                    if (ai[0] != 1.0)
                        Main.PlaySound(2, (int)position.X, (int)position.Y, 5);
                    localAI[0] = 12f;
                }
                player.phantasmTime = 2;
                if (flag && Main.myPlayer == owner)
                {
                    int shoot = 14;
                    float speed = 14f;
                    int Damage = player.inventory[player.selectedItem].damage;
                    float KnockBack = player.inventory[player.selectedItem].knockBack;
                    if (canShoot)
                    {
                        player.PickAmmo(player.inventory[player.selectedItem], ref shoot, ref speed, ref canShoot, ref Damage, ref KnockBack, false);
                        float num5 = player.inventory[player.selectedItem].shootSpeed * scale;
                        Vector2 vector2_2 = vector2_1;
                        Vector2 vector2_3 = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - vector2_2;
                        if (player.gravDir == -1.0)
                            vector2_3.Y = (Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector2_2.Y;
                        Vector2 vector2_4 = Vector2.Normalize(vector2_3);
                        if (float.IsNaN(vector2_4.X) || float.IsNaN(vector2_4.Y))
                            vector2_4 = -Vector2.UnitY;
                        vector2_4 *= num5;
                        if (vector2_4.X != velocity.X || vector2_4.Y != velocity.Y)
                            netUpdate = true;
                        velocity = vector2_4 * 0.55f;
                        for (int index1 = 0; index1 < 4; ++index1)
                        {
                            Vector2 vector2_5 = Vector2.Normalize(velocity) * speed * (float)(0.600000023841858 + Utils.NextFloat(Main.rand) * 0.800000011920929);
                            if (float.IsNaN(vector2_5.X) || float.IsNaN(vector2_5.Y))
                                vector2_5 = -Vector2.UnitY;
                            Vector2 vector2_6 = vector2_2 + Utils.RandomVector2(Main.rand, -15f, 15f);
                            int index2 = NewProjectile(vector2_6.X, vector2_6.Y, vector2_5.X, vector2_5.Y, shoot, Damage, KnockBack, owner, 0.0f, 0.0f);
                            Main.projectile[index2].noDropItem = true;
                        }
                    }
                    else
                        Kill();
                }
            }
            position = player.RotatedRelativePoint(player.MountedCenter, true) - Size / 2f;
            rotation = Utils.ToRotation(velocity) + num1;
            spriteDirection = direction;
            timeLeft = 2;
            player.ChangeDir(direction);
            player.heldProj = whoAmI;
            player.itemTime = 2;
            player.itemAnimation = 2;
            player.itemRotation = (float)Math.Atan2(velocity.Y * (double)direction, velocity.X * (double)direction);
            if (type == 460 || type == 611)
            {
                Vector2 vector2_2 = Main.OffsetsPlayerOnhand[player.bodyFrame.Y / 56] * 2f;
                if (player.direction != 1)
                    vector2_2.X = (float)player.bodyFrame.Width - vector2_2.X;
                if (player.gravDir != 1.0)
                    vector2_2.Y = (float)player.bodyFrame.Height - vector2_2.Y;
                Vector2 vector2_3 = vector2_2 - new Vector2((player.bodyFrame.Width - player.width), (player.bodyFrame.Height - 42)) / 2f;
                Center = player.RotatedRelativePoint(player.position + vector2_3, true) - velocity;
            }
            if (type == 615)
                position.Y += player.gravDir * 2f;
            if (type != 611 || alpha != 0)
                return;
            for (int index = 0; index < 2; ++index)
            {
                Dust dust = Main.dust[Dust.NewDust(position + velocity * 2f, width, height, 6, 0.0f, 0.0f, 100, Color.Transparent, 2f)];
                dust.noGravity = true;
                dust.velocity *= 2f;
                dust.velocity += Utils.ToRotationVector2(localAI[0]);
                dust.fadeIn = 1.5f;
            }
            float num10 = 18f;
            for (int index = 0; (double)index < num10; ++index)
            {
                if (Main.rand.Next(4) == 0)
                {
                    Vector2 Position = position + velocity + velocity * ((float)index / num10);
                    Dust dust = Main.dust[Dust.NewDust(Position, width, height, 6, 0.0f, 0.0f, 100, Color.Transparent, 1f)];
                    dust.noGravity = true;
                    dust.fadeIn = 0.5f;
                    dust.velocity += Utils.ToRotationVector2(localAI[0]);
                    dust.noLight = true;
                }
            }
        }