Esempio n. 1
0
        public override void AI()
        {
            Player  player = Main.player[npc.target];
            Vector2 target = npc.HasPlayerTarget ? player.Center : Main.npc[npc.target].Center;

            npc.netAlways = true;
            npc.rotation  = 0.0f;
            npc.TargetClosest(true);
            if (npc.life >= npc.lifeMax)
            {
                npc.life = npc.lifeMax;
            }
            if (npc.target < 0 || npc.target == 255 || player.dead || !player.active)
            {
                npc.TargetClosest(false);
                npc.direction  = 1;
                npc.velocity.Y = npc.velocity.Y - 0.1f;
                if (npc.timeLeft > 10)
                {
                    npc.timeLeft = 10;
                    return;
                }
            }
            if (this.stunned)
            {
                npc.velocity.Y = 0.0f;
                npc.velocity.X = 0.0f;
                ++this.stunnedTimer;
                if (this.stunnedTimer >= 105)
                {
                    this.stunned      = false;
                    this.stunnedTimer = 0;
                }
            }
            if (!this.secondState)
            {
                float distance = 160f;
                float k        = 1.26f;
                for (int count = 0; count < 10; count++)
                {
                    Vector2 spawn = npc.Center + distance * ((float)count * k).ToRotationVector2();
                    NPC.NewNPC((int)spawn.X, (int)spawn.Y, mod.NPCType("ProtectiveStone2"), 0, (float)npc.whoAmI, 0.0f, (float)count, 0.0f, 255);
                }
                this.secondState = true;
            }
            ++this.ai;
            npc.ai[0] = (float)this.ai * 1f;
            int  velocity = (int)((double)npc.ai[0] / 50f);
            bool speedB   = ((double)npc.life <= npc.lifeMax * 0.6 ? true : false);
            int  speedV   = (int)(speedB ? 6f : 0f);

            if ((double)npc.ai[0] < 350.0 && !this.stunned)
            {
                this.frame = 0;
                AntiarisHelper.MoveTowards(npc, target, (int)(Vector2.Distance(target, npc.Center) > 300 ? (Main.expertMode ? 24f : 20f) : (Main.expertMode ? 9f : 7f)) + speedV, 30f);
                for (int k = 0; k < 5 * (npc.ai[0] / 50); k++)
                {
                    float scale = 0.4f;
                    if (npc.ai[0] % 2 == 1)
                    {
                        scale = 0.65f;
                    }
                    Vector2 sDust  = npc.Center + ((float)Main.rand.NextDouble() * 6.283185f).ToRotationVector2() * (12f - (float)(velocity * 2));
                    int     index2 = Dust.NewDust(sDust - Vector2.One * 12f, 24, 24, 62, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, new Color(), 1f);
                    Main.dust[index2].position  -= new Vector2(2f);
                    Main.dust[index2].velocity   = Vector2.Normalize(npc.Center - sDust) * 1.5f * (float)(10.0 - (double)velocity * 2.0) / 10f;
                    Main.dust[index2].noGravity  = true;
                    Main.dust[index2].scale      = scale;
                    Main.dust[index2].customData = (object)npc;
                }
                npc.netUpdate = true;
                if ((double)npc.ai[0] % 349.0 == 0)
                {
                    this.buffTime += 1;
                    //CombatText.NewText(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), Color.Purple, "+1", false, false);
                }
            }
            else if ((double)npc.ai[0] >= 350.0 && (double)npc.ai[0] < 450.0)
            {
                this.stunned = true;
                this.frame   = 2;
                AntiarisHelper.MoveTowards(npc, target, (int)(Vector2.Distance(target, npc.Center) > 300 ? (Main.expertMode ? 24f : 20f) : (Main.expertMode ? 9f : 7f)) + speedV, 30f);
                for (int k = 0; k < 2 * (npc.ai[0] / 45); k++)
                {
                    float scale = 0.65f;
                    if (npc.ai[0] % 2 == 1)
                    {
                        scale = 0.81f;
                    }
                    Vector2 sDust  = npc.Center + ((float)Main.rand.NextDouble() * 6.283185f).ToRotationVector2() * (12f - (float)(velocity * 2));
                    int     index2 = Dust.NewDust(sDust - Vector2.One * 12f, 24, 24, 62, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, new Color(), 1f);
                    Main.dust[index2].position  -= new Vector2(2f);
                    Main.dust[index2].velocity   = Vector2.Normalize(npc.Center - sDust) * 1.5f * (float)(10.0 - (double)velocity * 2.0) / 10f;
                    Main.dust[index2].noGravity  = true;
                    Main.dust[index2].scale      = scale;
                    Main.dust[index2].customData = (object)npc;
                }
                player.AddBuff(mod.BuffType("Injured"), Main.expertMode ? 560 : 420, true);
                npc.netUpdate = true;
            }
            if ((double)npc.ai[0] > 450.0)
            {
                this.frame   = 1;
                this.stunned = false;
                npc.defense  = 40;
                if (!this.fastSpeed)
                {
                    if (Main.rand.Next(2) == 0)
                    {
                        this.fastSpeed = true;
                        npc.ai[2]      = 0f;
                    }
                    else
                    {
                        this.fastSpeed = true;
                        npc.ai[2]      = 1f;
                    }
                }
                else
                {
                    if ((double)npc.ai[2] == 0.0)
                    {
                        if ((double)npc.ai[0] % 50 == 0)
                        {
                            float speed = 21f + speedV;
                            if (Main.expertMode)
                            {
                                speed = 25f + speedV;
                            }
                            Vector2 vector_      = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                            float   x            = player.position.X + (float)(player.width / 2) - vector_.X;
                            float   y            = player.position.Y + (float)(player.height / 2) - vector_.Y;
                            float   distanse     = (float)Math.Sqrt((double)x * (double)x + (double)y * (double)y);
                            float   resuceFactor = speed / distanse;
                            npc.velocity.X = x * resuceFactor;
                            npc.velocity.Y = y * resuceFactor;
                        }
                    }
                    else
                    {
                        npc.alpha = 180;
                        if ((double)npc.ai[0] % 35 == 0)
                        {
                            float speed = 28f + speedV;
                            if (Main.expertMode)
                            {
                                speed = 30f + speedV;
                            }
                            Vector2 vector_      = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                            float   x            = player.position.X + (float)(player.width / 2) - vector_.X;
                            float   y            = player.position.Y + (float)(player.height / 2) - vector_.Y;
                            float   distanse     = (float)Math.Sqrt((double)x * (double)x + (double)y * (double)y);
                            float   resuceFactor = speed / distanse;
                            npc.velocity.X = x * resuceFactor;
                            npc.velocity.Y = y * resuceFactor;
                        }
                    }
                }
                npc.netUpdate = true;
            }
            else
            {
                npc.defense = 22;
            }
            if ((double)npc.ai[0] >= 650.0)
            {
                this.ai        = 0;
                npc.alpha      = 0;
                npc.ai[2]      = 0;
                this.fastSpeed = false;
            }
            if ((double)npc.life <= npc.lifeMax * 0.333)
            {
                npc.alpha   = 0;
                this.ai     = 0;
                this.frame  = 0;
                npc.ai[1]  += 1 + ((double)npc.life <= npc.lifeMax * 0.111 ? 1 : ((double)npc.life <= npc.lifeMax * 0.222 ? 1 : 0));
                npc.defense = 25;
                if ((double)npc.ai[1] < 200.0)
                {
                    this.frame     = 2;
                    npc.velocity.X = 0f; npc.velocity.Y = 0f;
                }
                if ((double)npc.ai[1] < 200.0)
                {
                    for (int k = 0; k < 3 * (npc.ai[1] / 50); k++)
                    {
                        float scale = 0.81f;
                        if (npc.ai[0] % 2 == 1)
                        {
                            scale = 1f;
                        }
                        Vector2 sDust  = npc.Center + ((float)Main.rand.NextDouble() * 6.283185f).ToRotationVector2() * (12f - (float)(velocity * 2));
                        int     index2 = Dust.NewDust(sDust - Vector2.One * 12f, 24, 24, 62, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, new Color(), 1f);
                        Main.dust[index2].position  -= new Vector2(2f);
                        Main.dust[index2].velocity   = Vector2.Normalize(npc.Center - sDust) * 1.5f * (float)(10.0 - (double)velocity * 2.0) / 10f;
                        Main.dust[index2].noGravity  = true;
                        Main.dust[index2].scale      = scale;
                        Main.dust[index2].customData = (object)npc;
                    }
                }
                if ((double)npc.ai[1] % 200.0 == 0 && (double)npc.ai[1] <= 399.0)
                {
                    this.attackTimer += 1;
                    if (this.attackTimer <= 2)
                    {
                        Vector2 shootPos   = npc.Center;
                        float   inaccuracy = 10f * (npc.life / npc.lifeMax);
                        Vector2 shootVel   = target - shootPos + new Vector2(Main.rand.NextFloat(-inaccuracy, inaccuracy), Main.rand.NextFloat(-inaccuracy, inaccuracy));
                        shootVel.Normalize();
                        shootVel *= 14f;
                        Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 88);
                        for (int k = 0; k < (Main.expertMode ? 5 : 3); k++)
                        {
                            Projectile.NewProjectile(shootPos.X + (float)(-100 * npc.direction) + (float)Main.rand.Next(-40, 41), shootPos.Y - (float)Main.rand.Next(-50, 40), shootVel.X, shootVel.Y, mod.ProjectileType("GolemCrystal2"), npc.damage / 3, 5f);
                        }
                    }
                    else
                    {
                        if (Main.expertMode)
                        {
                            for (int i = 0; i < 7; i++)
                            {
                                Projectile.NewProjectile((int)((player.position.X - 50) + Main.rand.Next(100)), (int)((player.position.Y - 50) + Main.rand.Next(100)), 0.0f, 0.0f, mod.ProjectileType("TowerKeeper2Sheet"), npc.damage / 3, 4.5f);
                            }
                        }
                        for (int k = 0; k < (Main.expertMode ? 8 : 5); k++)
                        {
                            Vector2 shootPos = player.position + new Vector2(Main.rand.Next(-300, 300), -1000);
                            Vector2 shootVel = new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(9f, 14f));
                            Projectile.NewProjectile(shootPos, shootVel, mod.ProjectileType("GolemCrystal2"), npc.damage / 2, 4.5f);
                        }
                        Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 88);
                        this.attackTimer = 0;
                    }
                }
                if ((double)npc.ai[1] > 200.0)
                {
                    AntiarisHelper.MoveTowards(npc, player.Center, 8f + (float)((double)npc.life <= npc.lifeMax * 0.111 ? 3 : ((double)npc.life <= npc.lifeMax * 0.222 ? 2 : 0)), 8f + (float)((double)npc.life <= npc.lifeMax * 0.111 ? 3 : ((double)npc.life <= npc.lifeMax * 0.222 ? 2 : 0)));
                }
                if (npc.ai[1] >= 350f)
                {
                    npc.ai[1] = 0f;
                }
                npc.netUpdate = true;
            }
            if ((double)npc.life <= npc.lifeMax * 0.135)
            {
                this.frame   = 1;
                this.stunned = true;
                if (!this.secondState2)
                {
                    float distance = 160f;
                    float k        = 1.26f;
                    for (int count = 0; count < 10; count++)
                    {
                        Vector2 spawn = npc.Center + distance * ((float)count * k).ToRotationVector2();
                        NPC.NewNPC((int)spawn.X, (int)spawn.Y, mod.NPCType("ProtectiveStone2"), 0, (float)npc.whoAmI, 0.0f, (float)count, 0.0f, 255);
                    }
                    this.secondState2 = true;
                }
                if (NPC.AnyNPCs(mod.NPCType("ProtectiveStone2")))
                {
                    //if ((double)this.ai % 215.0 == 0.0)
                    if (Main.rand.Next(5) == 0)
                    {
                        Projectile.NewProjectile((int)((npc.position.X - 500) + Main.rand.Next(1000)), (int)((npc.position.Y - 500) + Main.rand.Next(1000)), 0.0f, 0.0f, mod.ProjectileType("TowerKeeper2Sheet"), npc.damage / 3, 4.5f);
                    }
                    npc.dontTakeDamage = true;
                }
                else
                {
                    //if ((double)this.ai % 225.0 == 0.0)
                    if (Main.rand.Next(5) == 0)
                    {
                        Projectile.NewProjectile((int)((npc.position.X - 500) + Main.rand.Next(1000)), (int)((npc.position.Y - 500) + Main.rand.Next(1000)), 0.0f, 0.0f, mod.ProjectileType("TowerKeeper2Sheet"), npc.damage / 3, 4.5f);
                    }
                    npc.dontTakeDamage = false;
                }
            }
            if (this.buffTime >= 3)
            {
                ++this.buffTimeKey;
                if (this.buffTimeKey >= 120)
                {
                    player.AddBuff(BuffID.BrokenArmor, Main.expertMode ? 320 : 60, true);
                    player.AddBuff(BuffID.Slow, Main.expertMode ? 320 : 60, true);
                    Main.player[Main.myPlayer].statMana = 0;
                    this.buffTime    = 0;
                    this.buffTimeKey = 0;
                    npc.netUpdate    = true;
                }
            }
            if (this.checkDead)
            {
                npc.dontTakeDamage = true;
                this.ai            = 0;
                npc.ai[0]          = 0;
                npc.ai[1]          = 0;
                npc.velocity.X     = npc.velocity.Y = 0f;
                ++this.deadTimer;
                this.frame = 0;
                for (int k = 0; k < 5 * (this.deadTimer / 50); k++)
                {
                    npc.dontTakeDamage = true;
                    float scale = 0.81f;
                    if (npc.ai[0] % 2 == 1)
                    {
                        scale = 1f;
                    }
                    Vector2 sDust  = npc.Center + ((float)Main.rand.NextDouble() * 6.283185f).ToRotationVector2() * (12f - (float)(velocity * 2));
                    int     index2 = Dust.NewDust(sDust - Vector2.One * 12f, 24, 24, 62, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, new Color(), 1f);
                    Main.dust[index2].position  -= new Vector2(2f);
                    Main.dust[index2].velocity   = Vector2.Normalize(npc.Center - sDust) * 1.5f * (float)(10.0 - (double)velocity * 2.0) / 10f;
                    Main.dust[index2].noGravity  = true;
                    Main.dust[index2].scale      = scale;
                    Main.dust[index2].customData = (object)npc;
                }
                if (this.deadTimer == 100)
                {
                    Main.PlaySound(mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/NPCs/TowerKeeperDeath"), npc.position);
                }
                if (this.deadTimer >= 300)
                {
                    this.frame = 1;
                    if (this.deadTimer >= 400)
                    {
                        npc.life = 0;
                        npc.HitEffect(0, 1337);
                        npc.checkDead();
                        Main.PlaySound(4, (int)npc.position.X, (int)npc.position.Y, 43);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore1"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore2"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore2"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore2"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore3"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore3"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore3"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore4"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore4"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore4"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore4"), 1f);
                    }
                }
                if (this.deadTimer >= 0)
                {
                    Main.musicFade[Main.curMusic] = 1f / (float)(this.deadTimer / 15 * 0.5f);
                }
            }
        }
Esempio n. 2
0
        public override void AI()
        {
            Player  player = Main.player[npc.target];
            Vector2 target = npc.HasPlayerTarget ? player.Center : Main.npc[npc.target].Center;

            npc.netAlways = true;
            npc.TargetClosest(true);
            npc.rotation   = npc.velocity.X * 0.045f;
            this.moveSpeed = (int)((float)((double)npc.lifeMax / (double)npc.life) * 0.05f);
            if ((double)player.position.X >= (double)npc.position.X - 8.0)
            {
                npc.spriteDirection = 1;
            }
            else if ((double)player.position.X < (double)npc.position.X - 8.0)
            {
                npc.spriteDirection = -1;
            }
            if (((!Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) && npc.justHit) || npc.velocity.Y == 0f)
            {
                if ((npc.collideY) || (npc.collideX))
                {
                    npc.noTileCollide = true;
                }
                else if ((Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)))
                {
                    npc.noTileCollide = false;
                }
            }
            if (npc.target < 0 || npc.target == 255 || player.dead || !player.active)
            {
                npc.TargetClosest(false);
                npc.direction = 1;
                if (npc.velocity.X > 0f)
                {
                    npc.velocity.X = npc.velocity.X + 0.75f;
                }
                else
                {
                    npc.velocity.X = npc.velocity.X - 0.75f;
                }
                npc.velocity.Y = npc.velocity.Y - 0.1f;
                if (npc.timeLeft > 10)
                {
                    npc.timeLeft = 10;
                    return;
                }
            }
            if (!player.ZoneDesert)
            {
                AntiarisHelper.MoveTowards(npc, player.Center, 75f, 75f);
            }
            if (this.stunned)
            {
                npc.velocity.Y = 0.0f;
                npc.velocity.X = 0.0f;
                ++this.stunnedTimer;
                if (this.stunnedTimer >= 105)
                {
                    this.stunned      = false;
                    this.stunnedTimer = 0;
                }
            }
            if (this.end)
            {
                this.mv      = 0;
                this.ai      = 0;
                npc.ai[0]    = 0f;
                npc.ai[1]    = 0f;
                npc.ai[2]    = 0f;
                npc.ai[3]    = 0f;
                this.sAI     = false;
                this.stunned = false;
                this.end     = false;
            }
            if (player.ZoneDesert && !player.ZoneBeach)
            {
                this.StartSandstorm();
            }
            ++this.ai;
            if ((double)npc.ai[0] < 150.0 && !this.stunned && !this.sAI)
            {
                npc.ai[0]  = (float)this.ai * 1f;
                this.frame = 0;
                AntiarisHelper.MoveTowards(npc, target - new Vector2(0f, 250f), this.rage ? 40f : 30f, 30f);
                npc.ai[1] += 1f;
                if (npc.ai[1] % (float)(Main.expertMode ? 25 : 30) == 0)
                {
                    int y    = (int)(npc.Center.Y / 16f);
                    int x    = (int)(npc.Center.X / 16f);
                    int size = 100;
                    if (x < 10)
                    {
                        x = 10;
                    }
                    if (x > Main.maxTilesX - 10)
                    {
                        x = Main.maxTilesX - 10;
                    }
                    if (y < 10)
                    {
                        y = 10;
                    }
                    if (y > Main.maxTilesY - size - 10)
                    {
                        y = Main.maxTilesY - size - 10;
                    }
                    for (int finPos = y; finPos < y + size; finPos++)
                    {
                        Tile tile = Main.tile[x, finPos];
                        if (tile.active() && (Main.tileSolid[(int)tile.type] || tile.liquid != 0))
                        {
                            y = finPos;
                            break;
                        }
                    }
                    Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 - 56), 0f, 0f, mod.ProjectileType("Sandnado"), npc.damage / 2, 0f, Main.myPlayer, 16f, 15f);
                }
                npc.netUpdate = true;
            }
            else if ((double)npc.ai[0] >= 145.0 && !this.stunned && !this.sAI)
            {
                npc.noTileCollide = false;
                npc.velocity.X    = 0f;
                npc.velocity.Y    = 5f;
                this.frame        = 1;
                npc.netUpdate     = true;
                ++this.swarmerSpawnTimer;
                ++npc.ai[2];
                if ((double)npc.ai[2] > 60.0 && this.swarmerSpawnTimer > 60)
                {
                    Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                    NPC.NewNPC((int)(player.Center.X + 1200f), (int)(player.Center.Y - 1000f), 509, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                    if ((double)(npc.lifeMax - npc.life) > (double)(40.0 * 100f))
                    {
                        NPC.NewNPC((int)(player.Center.X - 1200f), (int)(player.Center.Y - 1000f), 508, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                    }
                    this.swarmerSpawnTimer -= (Main.expertMode ? 30 : 60);
                }
                if ((double)npc.ai[2] > 120.0)
                {
                    this.swarmerSpawnTimer = 0;
                    this.sAI  = true;
                    npc.ai[3] = 10f;
                }
                npc.netUpdate = true;
            }
            if ((double)npc.ai[3] >= 10.0 && (double)npc.ai[3] < 20.0)
            {
                this.mv          += 1 + (int)((npc.life > npc.lifeMax / 2 ? 0 : 1) + (npc.life > npc.lifeMax / 3 ? 0 : 1));
                this.frame        = 0;
                npc.noTileCollide = true;
                if (this.mv >= 150 && this.mv < 500)
                {
                    Vector2 vector2_1 = player.Center + new Vector2(0.0f, -600.0f);
                    float   speed     = 7f;
                    Vector2 vector2_2 = vector2_1 - npc.Center;
                    float   distance  = (float)Math.Sqrt((double)vector2_2.X * (double)vector2_2.X + (double)vector2_2.Y * (double)vector2_2.Y);
                    vector2_2   *= speed / distance;
                    npc.velocity = vector2_2;
                    if (this.mv > 350)
                    {
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                        npc.velocity.X = 0.0f;
                        npc.velocity.Y = 20f;
                        if ((double)npc.position.Y < (double)player.position.Y + 500.0)
                        {
                            this.mv = 425;
                        }
                    }
                    if (this.mv >= 425)
                    {
                        AntiarisHelper.MoveTowards(npc, target - new Vector2(0f, 25f), (npc.life <= npc.lifeMax * 0.35f) ? 435f : 275f, 30f);
                    }
                }
                else if (this.mv >= 650 && this.mv < 1000)
                {
                    Vector2 vector2_1 = player.Center + new Vector2(-600.0f, 0.0f);
                    float   speed     = 7f;
                    Vector2 vector2_2 = vector2_1 - npc.Center;
                    float   distance  = (float)Math.Sqrt((double)vector2_2.X * (double)vector2_2.X + (double)vector2_2.Y * (double)vector2_2.Y);
                    vector2_2   *= speed / distance;
                    npc.velocity = vector2_2;
                    if (this.mv > 850)
                    {
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                        npc.velocity.X = 20f;
                        npc.velocity.Y = 0.0f;
                        if ((double)npc.position.X < (double)player.position.X + 500.0)
                        {
                            this.mv = 925;
                        }
                    }
                    if (this.mv >= 925)
                    {
                        AntiarisHelper.MoveTowards(npc, target - new Vector2(0f, 25f), (npc.life <= npc.lifeMax * 0.35f) ? 435f : 275f, 30f);
                    }
                }
                else if (this.mv >= 1150 && this.mv < 1500)
                {
                    Vector2 vector2_1 = player.Center + new Vector2(600.0f, 0.0f);
                    float   speed     = 7f;
                    Vector2 vector2_2 = vector2_1 - npc.Center;
                    float   distance  = (float)Math.Sqrt((double)vector2_2.X * (double)vector2_2.X + (double)vector2_2.Y * (double)vector2_2.Y);
                    vector2_2   *= speed / distance;
                    npc.velocity = vector2_2;
                    if (this.mv > 1350)
                    {
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                        npc.velocity.X = -20f;
                        npc.velocity.Y = 0.0f;
                        if ((double)npc.position.X > (double)player.position.X - 500.0)
                        {
                            this.mv = 1425;
                        }
                    }
                    if (this.mv >= 1425)
                    {
                        AntiarisHelper.MoveTowards(npc, target - new Vector2(0f, 25f), (npc.life <= npc.lifeMax * 0.35f) ? 435f : 275f, 30f);
                    }
                }
                else
                {
                    AntiarisHelper.MoveTowards(npc, target, Vector2.Distance(target, npc.Center) > 500 ? (Main.expertMode ? 32f : 30f) : (Main.expertMode ? 13f : 11f), 30f);
                }
                if (this.mv >= 1600)
                {
                    this.mv   = 0;
                    npc.ai[3] = 20f;
                }
                npc.netUpdate = true;
            }
            else if ((double)npc.ai[3] >= 20.0 && (double)npc.ai[3] < 30.0)
            {
                AntiarisHelper.MoveTowards(npc, target, Vector2.Distance(target, npc.Center) > 500 ? (Main.expertMode ? 32f : 30f) : (Main.expertMode ? 13f : 11f), 30f);
                this.mv   += (int)0.2 + (int)((npc.life > npc.lifeMax / 2 ? 0 : 1) + (npc.life > npc.lifeMax / 3 ? 0 : 1));
                this.frame = 0;
                if (this.mv >= 100 && this.mv < 175)
                {
                    if (this.mv % 10 == 0)
                    {
                        Vector2 shootPos   = (npc.Top + new Vector2((npc.direction == -1 ? -150f : 150f), 155f)).RotatedBy(npc.rotation, npc.Center);
                        float   inaccuracy = 3f * (npc.life / npc.lifeMax);
                        Vector2 shootVel   = target - shootPos + new Vector2(Main.rand.NextFloat(-inaccuracy, inaccuracy), Main.rand.NextFloat(-inaccuracy, inaccuracy));
                        shootVel.Normalize();
                        shootVel *= 28f;
                        int k = Projectile.NewProjectile(shootPos, shootVel, 31, npc.damage / 2, 5f, Main.myPlayer);
                        Main.projectile[k].friendly = false;
                        Main.projectile[k].hostile  = true;
                        Main.projectile[k].scale    = 1.4f;
                    }
                }
                else if (this.mv >= 175)
                {
                    this.mv   = 0;
                    npc.ai[3] = 30f;
                }
                npc.netUpdate = true;
            }
            else if ((double)npc.ai[3] >= 30.0)
            {
                this.mv   += 2 + (int)((npc.life > npc.lifeMax / 2 ? 0 : 1) + (npc.life > npc.lifeMax / 3 ? 0 : 1));
                this.frame = 0;
                if (this.mv % 500 == 0)
                {
                    Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                    NPC.NewNPC((int)(player.Center.X - 1200f), (int)(player.Center.Y - 1000f), 508, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                    NPC.NewNPC((int)(player.Center.X + 1200f), (int)(player.Center.Y - 1000f), 508, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                }
                if (this.mv >= 650 && this.mv < 800)
                {
                    if (this.mv >= 650 && this.mv < 725)
                    {
                        if (player.position.Y < npc.position.Y + 650)
                        {
                            npc.velocity.Y -= 0.44f;
                        }
                    }
                    if (player.position.Y >= npc.position.Y + 650)
                    {
                        Vector2 targetPos   = player.Center;
                        float   speed       = 15f;
                        float   speedFactor = 0.7f;
                        Vector2 center      = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                        float   posX        = targetPos.X - center.X;
                        float   posY        = targetPos.Y - center.Y;
                        float   distance    = (float)Math.Sqrt((double)(posX * posX + posY * posY));
                        distance = speed / distance;
                        posX    *= distance;
                        posY    *= distance;
                        if (npc.velocity.X < posX)
                        {
                            npc.velocity.X = npc.velocity.X + speedFactor;
                            if (npc.velocity.X < 0f && posX > 0f)
                            {
                                npc.velocity.X = npc.velocity.X + speedFactor;
                            }
                        }
                        else if (npc.velocity.X > posX)
                        {
                            npc.velocity.X = npc.velocity.X - speedFactor;
                            if (npc.velocity.X > 0f && posX < 0f)
                            {
                                npc.velocity.X = npc.velocity.X - speedFactor;
                            }
                        }
                        if (npc.velocity.Y < posY)
                        {
                            npc.velocity.Y = npc.velocity.Y + speedFactor;
                            if (npc.velocity.Y < 0f && posY > 0f)
                            {
                                npc.velocity.Y = npc.velocity.Y + speedFactor;
                            }
                        }
                        else if (npc.velocity.Y > posY)
                        {
                            npc.velocity.Y = npc.velocity.Y - speedFactor;
                            if (npc.velocity.Y > 0f && posY < 0f)
                            {
                                npc.velocity.Y = npc.velocity.Y - speedFactor;
                            }
                        }
                        this.mv = 720;
                    }
                }
                else if (this.mv >= 1000 && this.mv < 1150)
                {
                    if (this.mv >= 1000 && this.mv < 1075)
                    {
                        if (player.position.Y < npc.position.Y + 650)
                        {
                            npc.velocity.Y -= 0.44f;
                        }
                    }
                    if (player.position.Y >= npc.position.Y + 650)
                    {
                        Vector2 targetPos   = player.Center;
                        float   speed       = 15f;
                        float   speedFactor = 0.7f;
                        Vector2 center      = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                        float   posX        = targetPos.X - center.X;
                        float   posY        = targetPos.Y - center.Y;
                        float   distance    = (float)Math.Sqrt((double)(posX * posX + posY * posY));
                        distance = speed / distance;
                        posX    *= distance;
                        posY    *= distance;
                        if (npc.velocity.X < posX)
                        {
                            npc.velocity.X = npc.velocity.X + speedFactor;
                            if (npc.velocity.X < 0f && posX > 0f)
                            {
                                npc.velocity.X = npc.velocity.X + speedFactor;
                            }
                        }
                        else if (npc.velocity.X > posX)
                        {
                            npc.velocity.X = npc.velocity.X - speedFactor;
                            if (npc.velocity.X > 0f && posX < 0f)
                            {
                                npc.velocity.X = npc.velocity.X - speedFactor;
                            }
                        }
                        if (npc.velocity.Y < posY)
                        {
                            npc.velocity.Y = npc.velocity.Y + speedFactor;
                            if (npc.velocity.Y < 0f && posY > 0f)
                            {
                                npc.velocity.Y = npc.velocity.Y + speedFactor;
                            }
                        }
                        else if (npc.velocity.Y > posY)
                        {
                            npc.velocity.Y = npc.velocity.Y - speedFactor;
                            if (npc.velocity.Y > 0f && posY < 0f)
                            {
                                npc.velocity.Y = npc.velocity.Y - speedFactor;
                            }
                        }
                        this.mv = 1070;
                    }
                }
                else
                {
                    AntiarisHelper.MoveTowards(npc, target, Vector2.Distance(target, npc.Center) > 500 ? (Main.expertMode ? 32f : 30f) : (Main.expertMode ? 13f : 11f), 30f);
                }
                if (this.mv >= 1150)
                {
                    this.end = true;
                }
                npc.netUpdate = true;
            }
            if (npc.life <= npc.lifeMax * 0.35f)
            {
                this.rage = true;
            }
            if (npc.life <= npc.lifeMax * 0.15f)
            {
                this.end          = true;
                this.frame        = 0;
                this.stunned      = true;
                npc.noTileCollide = false;
                Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                ++this.aiSECOND;
                if (this.aiSECOND % 2 == 0 && this.aiSECOND <= 120)
                {
                    var ShootPos = player.position + new Vector2(Main.rand.Next(-1000, 1000), -1000);
                    var ShootVel = new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(15f, 20f));
                    var k        = Projectile.NewProjectile(ShootPos, ShootVel, 31, npc.damage / 4, 1f);
                    Main.projectile[k].friendly    = false;
                    Main.projectile[k].hostile     = true;
                    Main.projectile[k].scale       = 1.4f;
                    Main.projectile[k].tileCollide = false;
                }
                if (this.aiSECOND >= 250 && this.aiSECOND < 320 && this.aiSECOND % 15 == 0)
                {
                    var shootPos   = (npc.Top + new Vector2((npc.direction == -1 ? -150f : 150f), 155f)).RotatedBy(npc.rotation, npc.Center);
                    var inaccuracy = 3f * (npc.life / npc.lifeMax);
                    var shootVel   = target - shootPos + new Vector2(Main.rand.NextFloat(-inaccuracy, inaccuracy), Main.rand.NextFloat(-inaccuracy, inaccuracy));
                    shootVel.Normalize();
                    shootVel *= 28f;
                    var k = Projectile.NewProjectile(shootPos, shootVel, 31, npc.damage / 2, 5f, Main.myPlayer);
                    Main.projectile[k].friendly = false;
                    Main.projectile[k].hostile  = true;
                    Main.projectile[k].scale    = 1.4f;
                }
                if (this.aiSECOND >= 450)
                {
                    this.aiSECOND = 0;
                }
                if (Main.expertMode)
                {
                    if (this.aiSECOND % 250 == 0)
                    {
                        NPC.NewNPC((int)(player.Center.X - 1200f), (int)(player.Center.Y - 1000f), 508, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                        NPC.NewNPC((int)(player.Center.X - 1200f), (int)(player.Center.Y - 1000f), 509, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                    }
                }
            }
        }