Example #1
0
        public override void NPCLoot()
        {
            if (npc.boss)
            {
                List <Projectile> itz = Idglib.Shattershots(npc.Center - new Vector2(npc.spriteDirection * 20, 100), npc.Center - new Vector2(npc.spriteDirection * 20, 100), new Vector2(0, 0), mod.ProjectileType("SnowCloud"), 40, 4f, 0, 1, true, 0, false, 1000);

                if (Main.expertMode)
                {
                    npc.DropBossBags();
                }
                else
                {
                    string [] dropitems = { "Starburster", "Snowfall", "IceScepter", "RubiedBlade", "IcicleFall" };
                    Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType(dropitems[Main.rand.Next(0, dropitems.Length)]));
                    Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("CryostalBar"), Main.rand.Next(15, 25));
                }
            }
            Achivements.SGAAchivements.UnlockAchivement("Cirno", Main.LocalPlayer);
            if (SGAWorld.downedCirno == false)
            {
                SGAWorld.downedCirno = true;
                Idglib.Chat("The snowflakes have thawed from your wings", 50, 200, 255);
            }
            //float targetX = npc.Center.X;
            //float targetY = npc.Center.Y;
            //NPC.NewNPC((int)npc.Center.X + 13, (int)npc.Center.Y - 2, mod.NPCType("GraySlime6"));
            //NPC.NewNPC((int)npc.Center.X - 13, (int)npc.Center.Y - 2, mod.NPCType("GraySlime6"));
        }
Example #2
0
        public override void AI()
        {
            base.AI();
            madeturrets = madeturrets + 1;
            if (laserblast == -1000)
            {
                laserblast = (int)Main.rand.Next(0, 50) - 300;
            }
            NPC ownerz = Main.npc[NPC.FindFirstNPC(mod.NPCType("CobaltWraith"))];

            if (ownerz != null)
            {
                if ((ownerz.modNPC as CobaltWraith).raged == true)
                {
                    laserblast = laserblast + 1;
                    Player P = Main.player[ownerz.target];
                    if (laserblast % 20 == 0 && laserblast % 300 > 200 && laserblast > 0 && P != null && Main.expertMode && (Main.netMode != 1))
                    {
                        Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), ProjectileID.WaterBolt, 20, 30, 0, 1, true, 0, true, 100);
                    }
                }
            }
            if (madeturrets == 5)
            {
                //madeturrets=true;
                int nexus                = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 24, mod.NPCType(Main.rand.Next(0, 100) < 50 ? "CobaltArmorBow" : "CobaltChainSawPiece"));
                NPC armpeice             = Main.npc[nexus];
                CopperArmorPiece newguy3 = armpeice.modNPC as CopperArmorPiece; newguy3.attachedID = npc.whoAmI;

                armpeice.lifeMax = (int)(npc.lifeMax * 0.75f); armpeice.ai[1] = -16; armpeice.ai[1] = -0f; armpeice.life = (int)(npc.lifeMax * (0.75f)); armpeice.knockBackResist = 1f; armpeice.netUpdate = true;
            }
        }
Example #3
0
        public void Phase1Hover(Player P, ref Vector2 PWhere, ref Vector2 DrakenWhere, ref Vector2 FlyTo, ref Vector2 FlySpeed, ref Vector2 FlyFriction)
        {
            //Hovering

            FlyFriction = new Vector2(0.95f, 0.95f);
            FlyTo       = PWhere - new Vector2((float)Math.Sin(npc.ai[0] / 73f) * 400f, 250);
            Vector2 Turnto = PWhere - DrakenWhere;

            Turnto.X           *= 3f;
            npc.rotation        = npc.rotation.AngleLerp((Turnto).ToRotation(), 0.025f);
            npc.spriteDirection = (FlyTo.X - DrakenWhere.X) > 0 ? 1 : -1;
            FlySpeed            = new Vector2(-8.20f, -8.20f) * Math.Min((FlyTo - DrakenWhere).Length() / 400f, 1f);

            Vector2 shootthere = PWhere - DrakenWhere;

            if (npc.ai[0] % 10 == 0 && npc.ai[0] % 100 > 60)
            {
                shootthere.Normalize();
                int prog = Projectile.NewProjectile(npc.Center, shootthere * 30f, ProjectileID.CursedFlameHostile, 80, 1f);
            }
            if (npc.ai[0] % 5 == 0 && npc.ai[0] % 100 > 60 && npc.ai[1] == 0)
            {
                Idglib.Shattershots(npc.Center, PWhere, new Vector2(0, 0), ProjectileID.CursedFlameHostile, 80, 50, 100, 3, false, 0, false, 100);
            }
        }
Example #4
0
 public override void AI()
 {
     npc.ai[3] += 1;
     if (npc.ai[3] > 60 * (Main.expertMode ? 10 : 25))
     {
         Player            target = Main.player[npc.target];
         List <Projectile> itz2   = Idglib.Shattershots(npc.Center, target.position, new Vector2(target.width / 2, target.height / 2), ProjectileID.HornetStinger, (int)((float)npc.damage / (Main.hardMode ? 6f : 2f)), 16f, 0, 1, true, 0f, false, 300);
         Main.PlaySound(SoundID.Item42, npc.Center);
         npc.active = false;
     }
 }
Example #5
0
        public override void AI()
        {
            projectile.velocity = new Vector2(projectile.velocity.X, projectile.velocity.Y * 0.95f);
            int q = 0;

            for (q = 0; q < 4; q++)
            {
                int dust = Dust.NewDust(projectile.position - new Vector2(100, 0), 200, 12, DustID.Smoke, 0f, projectile.velocity.Y * 0.4f, 100, colorcloud, 3f);
                Main.dust[dust].noGravity = true;
                //Main.dust[dust].velocity *= 1.8f;
                //Main.dust[dust].velocity.Y -= 0.5f;
                //Main.playerDrawDust.Add(dust);
            }
            projectile.ai[0]++;
            int    target2 = Idglib.FindClosestTarget(projectile.friendly ? 0 : 1, projectile.position, new Vector2(0, 0));
            Entity target;

            target = Main.player[target2] as Player;
            if (projectile.friendly)
            {
                target = Main.npc[target2] as NPC;
                //target=Main.player[target2];
            }

            if (target is Player)
            {
                Player targetasplayer = target as Player;
                if (targetasplayer.ownedProjectileCounts[mod.ProjectileType("SnowfallCloud")] > 0)
                {
                    projectile.Kill();
                }
            }

            if (target != null)
            {
                Vector2 dist = target.Center - projectile.position;
                if (System.Math.Abs(dist.X) < 250)
                {
                    if (projectile.ai[0] % rate == 0)
                    {
                        List <Projectile> itz = Idglib.Shattershots(projectile.Center + new Vector2(Main.rand.Next(-100, 100), 0), projectile.Center + new Vector2(Main.rand.Next(-200, 200), 500), new Vector2(0, 0), projectileid, (int)projectile.damage, 8f, 0, 1, true, 0, true, 220);
                        itz[0].friendly   = projectile.friendly;
                        itz[0].hostile    = projectile.hostile;
                        itz[0].coldDamage = true;
                        itz[0].netUpdate  = true;
                        itz[0].magic      = true;
                    }
                }
            }
        }
Example #6
0
        public override void OrderOfTheCrates(Player P)
        {
            if (pmlphase == 2 && pmlphasetimer > -300)
            {
                nonaispin = nonaispin + 0.6f;
                for (int a = 0; a < phase; a = a + 1)
                {
                    Cratesperlayer[a] = 4 + (a * 4);
                    for (int i = 0; i < Cratesperlayer[a]; i = i + 1)
                    {
                        float   boost  = 250f + (a * 50f);
                        Vector2 gohere = ((boost * (new Vector2((float)Math.Cos(Cratesangle[a, i]), (float)Math.Sin(Cratesangle[a, i]))))) + P.Center;
                        Cratesangle[a, i] = (a % 2 == 0 ? 1 : -1) * ((nonaispin * 0.01f) * (1f + a / 3f)) + 2.0 * Math.PI * ((i / (double)Cratesperlayer[a]));
                        Cratesdist[a, i]  = compressvar * 20f + ((float)a * 20f) * compressvar;

                        if (a == 1 && pmlphasetimer % 200 < 150 && pmlphasetimer < 2200 && pmlphasetimer > 1200)
                        {
                        }
                        else
                        {
                            Cratesvector[a, i] += (gohere - Cratesvector[a, i]) / 2f;
                        }
                        Vector2 it = new Vector2(P.Center.X - Cratesvector[a, i].X, P.Center.Y - Cratesvector[a, i].Y);
                        it.Normalize();


                        if (a == 0 && pmlphasetimer % 50 == i * 5 && pmlphasetimer < 1100 && pmlphasetimer > 0)
                        {
                            Idglib.Shattershots(Cratesvector[a, i], Cratesvector[a, i] + new Vector2(it.X * ((i + 1) % 2), it.Y * (i % 2)) * 50, new Vector2(0, 0), ProjectileID.GoldCoin, 45, (float)3, 0, 1, true, 0, false, 300);
                            Idglib.Shattershots(Cratesvector[a, i], Cratesvector[a, i] + new Vector2(it.X * ((i) % 2), it.Y * ((i + 1) % 2)) * 50, new Vector2(0, 0), ProjectileID.GoldCoin, 45, (float)4, 0, 1, true, 0, false, 300);
                        }

                        if (a == 1 && pmlphasetimer % 200 < 40 && pmlphasetimer < 2200 && pmlphasetimer > 1200 && pmlphasetimer % 20 == i)
                        {
                            Idglib.Shattershots(Cratesvector[a, i], Cratesvector[a, i] + it * 50, new Vector2(0, 0), ProjectileID.SilverCoin, 35, (float)12, 0, 1, true, 0, false, 300);
                        }

                        if (a == 2 && pmlphasetimer % 180 == i * 10 && pmlphasetimer > 2200 && pmlphasetimer < 2800)
                        {
                            Idglib.Shattershots(Cratesvector[a, i], Cratesvector[a, i] + it * 50, new Vector2(0, 0), ProjectileID.CopperCoin, 25, (float)3, 0, 1, true, 0, false, 200);
                        }
                    }
                }
            }
            else
            {
                base.OrderOfTheCrates(P);
            }
        }
Example #7
0
        public override void AI()
        {
            npc.ai[0]++;
            Player P = Main.player[npc.target];

            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(true);
            }
            npc.netUpdate = true;

            npc.ai[1]++;
            if (npc.ai[1] % 75 == 0 && Main.netMode != 1)
            {
                float   Speed   = 15f;
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int     damage  = 35;
                int     type    = mod.ProjectileType("WaterTornado");
                Main.PlaySound(23, (int)npc.position.X, (int)npc.position.Y, 17);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int   num54    = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                Main.projectile[num54].damage = (int)(npc.damage / 2);
                npc.netUpdate = true;
            }

            if (npc.ai[1] % 500 == 0 && npc.ai[1] > 0 && Main.expertMode)
            {
                List <Projectile> itz = Idglib.Shattershots(npc.Center, npc.Center + new Vector2(0, 200), new Vector2(0, 0), ProjectileID.WaterBolt, (int)(npc.damage), 4f, 180, 5, false, 0, true, 300);
                Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 21);
            }

            return;

            for (int k = 0; k < 255; k++)
            {
                Player player = Main.player[k];
                if (!player.dead)
                {
                    return;
                }
                else
                {
                    npc.life   = 0;
                    npc.active = false;
                    return;
                }
            }
        }
Example #8
0
        public override void AI()
        {
            npc.ai[0] += 1;
            npc.ai[2] += 1;
            NPC Master = Main.npc[(int)npc.ai[1]];

            if (!Master.active || npc.ai[1] + 1 < 1)
            {
                npc.active = false;
            }

            Vector2 masterloc = Master.Center - new Vector2(0, 0);
            bool    flyaway   = false;

            if (npc.ai[0] % 1100 > 700)
            {
                npc.TargetClosest();
                masterloc = Main.player[npc.target].Center - new Vector2(0, 0);
                if (Main.player[npc.target].dead)
                {
                    flyaway = true;
                }
            }
            else
            {
                if (this.GetType() == typeof(BossFlyMiniboss1) && npc.ai[2] % 300 == 0 && npc.ai[0] > 700 && Main.expertMode)
                {
                    Player            target = Main.player[npc.target];
                    List <Projectile> itz2   = Idglib.Shattershots(npc.Center, target.position, new Vector2(target.width / 2, target.height / 2), ProjectileID.Stinger, (int)((float)npc.damage / 4f), 8f, 0, 1, true, 0f, false, 300);
                    Main.PlaySound(SoundID.Item42, npc.Center);
                }
            }
            if (flyaway)
            {
                masterloc = -(Master.Center - npc.Center);
            }

            Vector2 masterdist   = (masterloc - npc.Center);
            Vector2 masternormal = masterdist; masternormal.Normalize();

            npc.velocity += masternormal * 0.25f;
            npc.direction = (npc.velocity.X > 0f).ToDirectionInt();
            if (npc.velocity.Length() > 8f)
            {
                npc.velocity.Normalize(); npc.velocity *= 8f;
            }
        }
Example #9
0
        public override void AI()
        {
            base.AI();
            int npctype = mod.NPCType("Cratrosity");

            if (NPC.CountNPCS(npctype) > 0)
            {
                NPC myowner = Main.npc[NPC.FindFirstNPC(npctype)];
                npc.ai[0] += Main.rand.Next(0, 4);
                if (myowner.ai[0] % 10 == 0 && npc.ai[0] % 300 < 90)
                {
                    Player            P   = Main.player[myowner.target];
                    List <Projectile> itz = Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), ProjectileID.PlatinumCoin, 30, 8, 0, 1, true, 0, false, 220);
                    itz[0].aiStyle = 5;
                }
            }
        }
Example #10
0
        public void overAI(NPC npc2)
        {
            base.AI();
            shooting2 = shooting2 + 1;
            Player P = Main.player[npc.target];

            npc2.ai[3] += Main.rand.Next(-2, 4);
            int npctype = mod.NPCType("Cirno");

            if (NPC.CountNPCS(npctype) > 0)
            {
                NPC     myowner = Main.npc[NPC.FindFirstNPC(npctype)];
                Vector2 here    = myowner.Center;
                if (npc2.ai[3] % 400 > 150)
                {
                    float leftorright = (npc.type == mod.NPCType("CirnoIceFairy2")) ? -128f : 128f;
                    if (npc2.ai[3] % 300 > 200)
                    {
                        here        = P.Center;
                        leftorright = (npc.type == mod.NPCType("CirnoIceFairy2")) ? 220f : -220f;
                    }
                    float bobbing = -30f + (float)Math.Sin(npc.ai[3] / 31) * 20f;
                    npc2.velocity = (npc2.velocity + ((here + new Vector2(leftorright, bobbing) - (npc2.position)) * 0.02f) * 0.01f) * 0.99f;
                    npc.aiStyle   = -1;
                }
                else
                {
                    npc.aiStyle = 22;
                }
                if (shooting2 % 400 > 250)
                {
                    if (shooting2 % 15 == 0)
                    {
                        Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 30, 1f, -0.25f + Main.rand.NextFloat() / 2f);
                        Idglib.Shattershots(npc.Center, myowner.Center, new Vector2(0, 0), mod.ProjectileType("CirnoIceShard"), 30, 15, 0, 1, true, (float)Math.Sin((float)shooting2 / 120) * 1, false, 180);
                    }
                }
                npc2.timeLeft = 99;
            }
            else
            {
                npc2.active = false;
            }
        }
Example #11
0
 public override void AI()
 {
     npc.spriteDirection = npc.velocity.X > 0 ? -1 : 1;
     shooting            = shooting + 1;
     if (shooting % 200 == 0)
     {
         npc.netUpdate = true;
         Player P = Main.player[npc.target];
         if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
         {
         }
         else
         {
             if (Collision.CanHitLine(new Vector2(npc.Center.X, npc.Center.Y), 1, 1, new Vector2(P.Center.X, P.Center.Y), 1, 1))
             {
                 Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), 118, npc.lifeMax > 2000 ? 25 : 40, (float)Main.rand.Next(60, 80) / 6, 35, 2, true, 0, true, 100);
             }
         }
     }
 }
Example #12
0
        public override void AI()
        {
            base.AI();
            madeturrets = madeturrets + 1;
            if (laserblast == -1000)
            {
                laserblast = (int)Main.rand.Next(0, 50) - 300;
            }
            int findthem = NPC.FindFirstNPC(mod.NPCType("CobaltWraith"));

            if (findthem >= 0 && findthem < Main.maxNPCs)
            {
                NPC ownerz = Main.npc[findthem];
                if ((ownerz.modNPC as CobaltWraith).raged == true)
                {
                    laserblast = laserblast + 1;
                    Player P = Main.player[ownerz.target];
                    if (laserblast % 20 == 0 && laserblast % 400 > 200 && laserblast > 0 && P != null && Main.expertMode && (Main.netMode != 1))
                    {
                        if (mode == 0)
                        {
                            //if (laserblast % 400 > 300)
                            //Idglib.Shattershots(npc.Center, npc.Center + new Vector2(Math.Sign(P.Center.X - npc.Center.X) * 8f, 0), Vector2.Zero, ProjectileID.WaterBolt, 20, 30, 0, 1, true, 0, true, 100);
                        }
                        else
                        {
                            Idglib.Shattershots(npc.Center, npc.Center + Vector2.UnitY, Vector2.Zero, ProjectileID.WaterBolt, 20, 30, 0, 1, true, 0, true, 100);
                        }
                    }
                }
            }
            if (madeturrets == 5)
            {
                //madeturrets=true;
                int nexus                = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y - 24, mod.NPCType(Main.rand.Next(0, 100) < 50 && mode == 0 ? "CobaltArmorBow" : "CobaltChainSawPiece"));
                NPC armpeice             = Main.npc[nexus];
                CopperArmorPiece newguy3 = armpeice.modNPC as CopperArmorPiece; newguy3.attachedID = npc.whoAmI;

                armpeice.lifeMax = (int)(npc.lifeMax * 0.75f); armpeice.ai[1] = -16; armpeice.ai[1] = -0f; armpeice.life = (int)(npc.lifeMax * (0.75f)); armpeice.knockBackResist = 1f; armpeice.netUpdate = true;
            }
        }
        public void DropBolders()
        {
            Player  P       = Main.player[npc.target];
            Vector2 theside = new Vector2((P.Center.X - npc.Center.X > 0 ? -300f : 300f) * (0.5f + (float)Math.Sin((double)npc.ai[0] / 120f) * 0.7f), -200);

            Vector2 itt      = ((P.Center + theside) - npc.Center);
            float   locspeed = 0.25f;

            npc.velocity = npc.velocity * 0.90f;

            itt.Normalize();
            npc.velocity = npc.velocity + (itt * locspeed);

            npc.rotation = (float)Math.Cos((double)npc.ai[0] / 6f) * 1f;


            if (npc.ai[0] % 90 == 0)
            {
                Idglib.Shattershots(npc.Center, P.Center + new Vector2((P.Center.X - npc.Center.X) > 0 ? 600 : -600, 0), new Vector2(P.width, P.height), ProjectileID.Boulder, 50, 3, npc.ai[3] * 50, 1 + (int)npc.ai[3], true, 0, true, 300);
            }
        }
        /*public override string Texture
         * {
         *      get { return "Terraria/Buff_" + BuffType; }
         * }*/


        public override void AI()
        {
            base.AI();
            int npctype = mod.NPCType("Cratrogeddon");

            if (Hellion.Hellion.GetHellion() != null)
            {
                npctype = mod.NPCType("Hellion");
            }
            if (NPC.CountNPCS(npctype) > 0)
            {
                for (int i = 0; i <= Main.maxPlayers; i++)
                {
                    Player thatplayer = Main.player[i];
                    if (thatplayer.active && !thatplayer.dead)
                    {
                        thatplayer.AddBuff(BuffType, 2);
                    }
                }

                NPC myowner = Main.npc[NPC.FindFirstNPC(npctype)];
                npc.ai[0]    += Main.rand.Next(0, 4);
                npc.netUpdate = true;
                npc.velocity  = npc.velocity * 0.95f;
                if (myowner.ai[0] % 350 > 250)
                {
                    npc.velocity = npc.velocity * 0.45f;
                }
                if (myowner.ai[0] % 150 == 140)
                {
                    Player            P   = Main.player[myowner.target];
                    List <Projectile> itz = Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), ModContent.ProjectileType <GlowingPlatinumCoin>(), 45, 8, 0, 1, true, 0, false, 220);
                    itz[0].aiStyle = 5;
                }
            }
            else
            {
                npc.active = false;
            }
        }
        public override void AI()
        {
            npc.spriteDirection = npc.velocity.X > 0 ? 1 : -1;
            if (!Main.player[npc.target].dead)
            {
                Vector2 mix = Main.player[npc.target].Center - npc.Center;
                mix.Normalize();
                npc.velocity += mix * 0.03f;
                //npc.velocity+=new Vector2(0,-0.20f);
                npc.ai[3] += 1;

                if (npc.ai[3] % 800 > 600)
                {
                    npc.noTileCollide = true;
                    int DustID2 = Dust.NewDust(npc.Center, 0, 0, mod.DustType("TornadoDust"), (npc.velocity.X * -2f) - 0.5f, npc.velocity.Y * -0.5f, 20, default(Color), 1.5f);
                    Main.dust[DustID2].noGravity = true;
                    if (npc.ai[3] % 800 < 785)
                    {
                        npc.velocity *= 0.75f;
                    }
                    npc.velocity += mix * 2f;
                }
                else
                {
                    if (npc.ai[3] % 600 == 0 && Main.expertMode)
                    {
                        List <Projectile> itz = Idglib.Shattershots(npc.Center, Main.player[npc.target].Center, new Vector2(0, 0), ProjectileID.SapphireBolt, 50, 8f, 1, 1, true, 0, true, 300);
                    }
                    npc.noTileCollide = false;
                }
                Vector2 capvelo = npc.velocity;
                capvelo.Normalize();
                npc.velocity  = capvelo * Math.Min(npc.velocity.Length(), 20f);
                npc.velocity *= 0.97f;
            }
        }
Example #16
0
        public override void AI()
        {
            Player     P      = Main.player[npc.target];
            Cratrosity origin = npc.modNPC as Cratrosity;

            pmlphasetimer--;
            npc.dontTakeDamage = false;
            if (pmlphasetimer > 0)
            {
                //phase 1
                if (pmlphase == 1)
                {
                    OrderOfTheCrates(P);
                    origin.compressvargoal = 4f;
                    origin.themode         = 1;
                    npc.rotation           = Idglib.LookAt(npc.Center, P.Center);
                    npc.dontTakeDamage     = true;
                    npc.velocity           = (npc.velocity * 0.97f);
                    if (pmlphasetimer < 1000)
                    {
                        Vector2 it = new Vector2(P.Center.X - npc.Center.X, P.Center.Y - npc.Center.Y);
                        it.Normalize();
                        if (pmlphasetimer % 120 == 0)
                        {
                            npc.velocity = (it * (30f - pmlphasetimer * 0.02f));
                        }
                        if (pmlphasetimer % 120 < 60 && pmlphasetimer % 20 == 0)
                        {
                            Idglib.Shattershots(npc.Center, npc.Center + it * 50, new Vector2(0, 0), ProjectileID.NanoBullet, 40, (float)6, 80, 3, true, 0, false, 600);
                            Idglib.PlaySound(13, npc.Center, 0);
                        }
                    }
                }
                //phase 2
                if (pmlphase == 2)
                {
                    npc.dontTakeDamage = true;
                    OrderOfTheCrates(P);
                    npc.velocity = (npc.velocity * 0.77f);
                    Vector2 it = new Vector2(P.Center.X - npc.Center.X, P.Center.Y - npc.Center.Y);
                    it.Normalize();
                    npc.velocity += it * 0.3f;
                    npc.Opacity  += (0.1f - npc.Opacity) / 30f;
                }

                //phase 3
                if (pmlphase == 3)
                {
                    npc.ai[0] = 0;

                    if (pmlphasetimer > 1000)
                    {
                        int spawnedint = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CratrosityNight"));
                        spawnedint    = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CratrosityLight"));
                        pmlphasetimer = 105;
                        Idglib.Chat("Give in to Temptation!", 144, 79, 16);
                    }

                    if (NPC.CountNPCS(mod.NPCType("Cratrosity")) > 0)
                    {
                        pmlphasetimer = 100;
                    }

                    npc.dontTakeDamage = true;
                    base.OrderOfTheCrates(P);
                    npc.velocity = (npc.velocity * 0.77f);
                    Vector2 it = new Vector2(P.Center.X - npc.Center.X, P.Center.Y - npc.Center.Y);
                    it.Normalize();
                    npc.velocity += it * 0.3f;
                    npc.Opacity  += (0.1f - npc.Opacity) / 30f;
                }

                //phase 4
                if (pmlphase > 3)
                {
                    npc.velocity /= 1.5f;
                    if (pmlphasetimer > 1000)
                    {
                        pmlphasetimer = 100;
                    }
                }
            }
            else
            {
                npc.rotation = npc.rotation * 0.85f;
                npc.Opacity += (1f - npc.Opacity) / 30f;
                base.AI();
            }


            if (phase < 1)
            {
                int val;
                val = (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.WoodenCrate.ToString()))) +
                      (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.IronCrate.ToString()))) +
                      (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.GoldenCrate.ToString()))) +
                      (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.DungeonFishingCrate.ToString()))) +
                      (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.JungleFishingCrate.ToString()))) +
                      (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + evilcratetype.ToString()))) +
                      (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.HallowedFishingCrate.ToString()))) +
                      (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.FloatingIslandFishingCrate.ToString())));
                val += NPC.CountNPCS(mod.NPCType("CratrosityCrateOfWitheredWeapon")) +
                       NPC.CountNPCS(mod.NPCType("CratrosityCrateOfWitheredArmor")) +
                       NPC.CountNPCS(mod.NPCType("CratrosityCrateOfPoisoned")) +
                       NPC.CountNPCS(mod.NPCType("CratrosityCrateOfSlowing"));
                if (val > 0)
                {
                    npc.dontTakeDamage = true;
                }
            }
        }
Example #17
0
        public override void AI()
        {
            Player P = Main.player[npc.target];

            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active || Main.dayTime)
            {
                npc.TargetClosest(false);
                P = Main.player[npc.target];
                if (!P.active || P.dead || Main.dayTime)
                {
                    float speed = ((-10f));
                    npc.velocity = new Vector2(npc.velocity.X, npc.velocity.Y + speed);
                    npc.active   = false;
                }
            }
            else
            {
                npc.netUpdate = true;
                npc.timeLeft  = 99999;
                if (npc.ai[0] == 0)
                {
                    npc.position = P.position + new Vector2(0, 500f);
                }
                npc.ai[0] = npc.ai[0] + 1;
                if (npc.ai[0] == 2)
                {
                    normhp    = npc.life;
                    bosses[0] = NPC.NewNPC((int)npc.Center.X + 900, (int)npc.Center.Y - 32, NPCID.Spazmatism);
                    Main.npc[bosses[0]].boss     = false;
                    Main.npc[bosses[0]].timeLeft = 99999;
                    bossattach[0]                  = -1;
                    bosses[1]                      = NPC.NewNPC((int)npc.Center.X + 900, (int)npc.Center.Y - 32, NPCID.SkeletronPrime);
                    Main.npc[bosses[1]].boss       = false;
                    Main.npc[bosses[1]].timeLeft   = 99999;
                    Main.npc[bosses[1]].defDefense = 5000;
                    Main.npc[bosses[1]].defense    = 5000;
                    bossattach[1]                  = bosses[0];
                    bosses[2]                      = NPC.NewNPC((int)npc.Center.X - 900, (int)npc.Center.Y - 32, NPCID.Retinazer);
                    Main.npc[bosses[2]].boss       = false;
                    Main.npc[bosses[2]].timeLeft   = 99999;
                    bossattach[2]                  = -1;
                    bosses[3]                      = NPC.NewNPC((int)npc.Center.X - 900, (int)npc.Center.Y - 32, NPCID.SkeletronPrime);
                    Main.npc[bosses[3]].boss       = false;
                    Main.npc[bosses[3]].timeLeft   = 99999;
                    Main.npc[bosses[3]].defDefense = 5000;
                    Main.npc[bosses[3]].defense    = 5000;
                    bossattach[3]                  = bosses[2];
                    bosses[4]                      = NPC.NewNPC((int)npc.Center.X + 900, (int)npc.Center.Y - 32, NPCID.TheDestroyer);
                    Main.npc[bosses[4]].boss       = false;
                    Main.npc[bosses[4]].timeLeft   = 99999;
                    //Main.npc[bosses[4]].active=false;
                    bossattach[4]                = bosses[1];
                    bosses[5]                    = NPC.NewNPC((int)npc.Center.X - 900, (int)npc.Center.Y - 32, NPCID.TheDestroyer);
                    Main.npc[bosses[5]].boss     = false;
                    Main.npc[bosses[5]].timeLeft = 99999;
                    bossattach[5]                = bosses[3];
                    //Main.npc[bosses[5]].active=false;



                    npc.life = npc.life + Main.npc[bosses[0]].life;
                    npc.life = npc.life + Main.npc[bosses[1]].life;
                    npc.life = npc.life + Main.npc[bosses[2]].life;
                    npc.life = npc.life + Main.npc[bosses[3]].life;
                    npc.life = npc.life + Main.npc[bosses[4]].life;
                    npc.life = npc.life + Main.npc[bosses[5]].life;

                    npc.lifeMax = npc.life;
                }
                if (npc.ai[0] > 2)
                {
                    if (npc.ai[0] == 3)
                    {
                        for (int i = 0; i <= 5; i++)
                        {
                            NPC thisboss = Main.npc[bosses[i]];
                            if (thisboss == null || thisboss.active == false)
                            {
                                npc.Center = P.Center - new Vector2(0, 128);
                                npc.active = false;
                                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Mechacluskerf"));

                                for (int z = 0; z <= Main.maxNPCs; z++)
                                {
                                    NPC zz = Main.npc[z];
                                    if (zz.type == NPCID.SkeletronHand ||
                                        zz.type == NPCID.SkeletronHead ||
                                        zz.type == NPCID.SkeletronPrime ||
                                        zz.type == NPCID.Retinazer ||
                                        zz.type == NPCID.Spazmatism ||
                                        zz.type == NPCID.TheDestroyer ||
                                        zz.type == NPCID.TheDestroyerBody ||
                                        zz.type == NPCID.TheDestroyerTail)
                                    {
                                        zz.active = false;
                                    }
                                }
                                Idglib.Chat("Boss failed to properly spawn, boss item has been given back", 255, 255, 255);
                                break;
                            }
                        }
                    }

                    if (phase < 60)
                    {
                        npc.life = normhp;
                    }
                    Vector2 averagevec = npc.Center;
                    int     divider    = 1;

                    for (int i = 0; i <= 5; i++)
                    {
                        NPC thisboss = Main.npc[bosses[i]];
                        if (bosses[i] > -1 || npc.ai[0] < 30)
                        {
                            thisboss.boss = false;
                            if (thisboss.life < 1 && npc.ai[0] > 30)
                            {
                                bossactive[i] = 0;
                                if (i == 0)
                                {
                                    Main.npc[bosses[1]].defDefense = 20;
                                    Main.npc[bosses[1]].defense    = 20;
                                    bossattach[1] = -1;
                                }
                                if (i == 2)
                                {
                                    Main.npc[bosses[3]].defDefense = 20;
                                    Main.npc[bosses[3]].defense    = 20;
                                    bossattach[3] = -1;
                                }


                                thisboss.active = false;
                                bossattach[i]   = -1;
                                bosses[i]       = 0;
                            }
                            else
                            {
                                if (phase < 1)
                                {
                                    npc.life = npc.life + thisboss.life;
                                }
                            }
                        }

                        if (thisboss.active == true)
                        {
                            if (thisboss.life > 0 && bossactive[i] > 0)
                            {
                                divider    = divider + 1;
                                averagevec = averagevec + thisboss.Center;
                                if (bossattach[i] > -1)
                                {
                                    NPC myfellaboss = Main.npc[bossattach[i]];
                                    if (myfellaboss.active == true)
                                    {
                                        Main.npc[bosses[i]].position = myfellaboss.Center;
                                    }
                                }
                            }
                        }
                    }
                    //averagevec=averagevec-npc.Center;
                    if (divider > 1)
                    {
                        shooting = shooting + 1;
                        float shoottype = 0;
                        if (divider < 4)
                        {
                            if (shooting % 1200 < 700)
                            {
                                if (shooting % 1200 > 100)
                                {
                                    shoottype = 1;
                                    if (shooting % 200 == 0 && shooting % 8 == 0)
                                    {
                                        for (float f = 0; f < MathHelper.TwoPi; f += MathHelper.Pi / 10f)
                                        {
                                            float angle = (shooting / 60f) + f;
                                            int   proj  = Projectile.NewProjectile(npc.Center, angle.ToRotationVector2() * 24f, mod.ProjectileType("HellionBolt"), 30, 15f);
                                            Main.projectile[proj].timeLeft  = 200;
                                            Main.projectile[proj].netUpdate = true;
                                            //Idglib.Shattershots(npc.position, P.position + P.velocity * (1f + (shooting - 120 % 160) / 150f), new Vector2(P.width, P.height), 88, 25, 8, 0, 1, true, 0, false, 450);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (shooting % 1200 > 850)
                                {
                                    shoottype = 2;
                                    if (shooting % 10 == 0)
                                    {
                                        for (float f = -1; f < 2; f += 2f)
                                        {
                                            float angle = (shooting / 20f) * f;
                                            int   proj  = Projectile.NewProjectile(npc.Center, angle.ToRotationVector2() * 18f, mod.ProjectileType("HellionBolt"), 30, 15f);
                                            Main.projectile[proj].timeLeft  = 200;
                                            Main.projectile[proj].netUpdate = true;
                                        }
                                    }
                                }
                            }

                            if (shoottype == 1)
                            {
                                if ((shooting + 90) % 180 == 0 && Main.expertMode)
                                {
                                    if (Main.npc[bosses[1]].active && Main.npc[bosses[1]].type == NPCID.SkeletronPrime)
                                    {
                                        Vector2           Centerhere = (P.position - Main.npc[bosses[1]].Center);
                                        List <Projectile> itz        = Idglib.Shattershots(Main.npc[bosses[1]].Center, P.position, new Vector2(P.width, P.height), ProjectileID.SaucerMissile, 25, 10, 80, 2, false, 0, false, 450);
                                        itz[0].localAI[1] = -30;
                                        itz[1].localAI[1] = -30;
                                    }
                                }
                                if (shooting % 180 == 0 && Main.expertMode)
                                {
                                    if (Main.npc[bosses[3]].active && Main.npc[bosses[3]].type == NPCID.SkeletronPrime)
                                    {
                                        Vector2           Centerhere = (P.position - Main.npc[bosses[3]].Center);
                                        List <Projectile> itz        = Idglib.Shattershots(Main.npc[bosses[3]].Center, P.position, new Vector2(P.width, P.height), ProjectileID.SaucerMissile, 25, 10, 80, 2, false, 0, false, 450);
                                        itz[0].localAI[1] = -30;
                                        itz[1].localAI[1] = -30;
                                    }
                                }
                            }

                            if (shoottype == 2)
                            {
                                if (true)
                                {
                                    if (Main.npc[bosses[1]].active && Main.npc[bosses[1]].type == NPCID.SkeletronPrime)
                                    {
                                        Main.npc[bosses[1]].position.X -= 12.15f;
                                    }
                                }
                                if (true)
                                {
                                    if (Main.npc[bosses[3]].active && Main.npc[bosses[3]].type == NPCID.SkeletronPrime)
                                    {
                                        Main.npc[bosses[3]].position.X += 12.15f;
                                    }
                                }
                            }
                        }
                        averagevec = averagevec / divider;
                        Vector2 lastpos = npc.position;
                        npc.position        = npc.position + ((averagevec - npc.position) / 15);
                        rotatationsensation = (int)(rotatationsensation + (5));
                    }
                    else
                    {
                        if (phase < 60)
                        {
                            phase = phase + 1;
                            rotatationsensation = (int)(rotatationsensation + (5 + (phase / 33)));
                        }
                        else
                        {
                            shooting            = shooting + 1;
                            rotatationsensation = (int)(rotatationsensation + 12);
                            phase = phase + 1;
                            int expert = 0;
                            if (Main.expertMode)
                            {
                                expert = 1;
                            }
                            if (shooting % ((int)(30 + (npc.life / 5000))) == 0)
                            {
                                Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), 100, 25, 12, 60, 2 + expert, true, 0, true, 300);
                            }

                            if (shooting % (int)(60) < 30 && shooting % 3 == 0)
                            {
                                Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), 83, 20, 3 + expert, 0, 1, true, (float)shooting / 22, false, 300);
                            }
                            if ((shooting - 30) % (int)(60) < 30 && shooting % 3 == 0)
                            {
                                Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), 83, 20, 3 + expert, 0, 1, true, -(float)shooting / 22, false, 300);
                            }
                            if (phase < 240)
                            {
                                npc.velocity = new Vector2(((P.position.X - 500) - npc.position.X) / 32, ((P.position.Y - 150) - npc.position.Y) / 16);
                            }
                            else
                            {
                                npc.velocity = new Vector2(((P.position.X + 500) - npc.position.X) / 32, ((P.position.Y - 150) - npc.position.Y) / 16);
                                if (phase > 420)
                                {
                                    phase = 60;
                                }
                            }
                        }
                    }
                }



                //npc.spriteDirection = (int)npc.ai[1]*14;
            }



            //int dust = Dust.NewDust(npc.Center, 0, 0, 178, 0, 5, 0, new Color=Main.hslToRgb((float)(npc.ai[0]/300)%1, 1f, 0.9f), 1f);
            int  dustType  = 43;                                                                 //Main.rand.Next(139, 143);
            int  dustIndex = Dust.NewDust(npc.Center + new Vector2(-16, -16), 32, 32, dustType); //,0,5,0,new Color=Main.hslToRgb((float)(npc.ai[0]/300)%1, 1f, 0.9f),1f);
            Dust dust      = Main.dust[dustIndex];

            dust.velocity.X     = dust.velocity.X + Main.rand.Next(-50, 51) * 0.01f;
            dust.velocity.Y     = dust.velocity.Y + Main.rand.Next(-50, 51) * 0.01f;
            dust.scale         *= 3f + Main.rand.Next(-30, 31) * 0.01f;
            dust.fadeIn         = 0f;
            dust.noGravity      = true;
            dust.color          = Main.hslToRgb((float)(npc.ai[0] / 300) % 1, 1f, 0.9f);
            npc.spriteDirection = rotatationsensation;
        }
        public override void AI()
        {
            doCharge -= 1;
            Player P = Target;

            npc.localAI[0] -= 1;
            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(false);
                P = Main.player[npc.target];
                if (!P.active || P.dead)
                {
                    float speed = ((-10f));
                    npc.velocity = new Vector2(npc.velocity.X, npc.velocity.Y + speed);
                    npc.active   = false;
                }
            }
            else
            {
                if (npc.localAI[3] > 0)
                {
                    if (npc.localAI[3] < 100)
                    {
                        npc.dontTakeDamage = true;
                        npc.velocity      *= 0.85f;
                        npc.localAI[3]    += 1;
                        if (phase > 2 && npc.localAI[3] >= 0)
                        {
                            npc.frameCounter = 16f * (1f - ((npc.localAI[3]) / 100f));
                        }
                        else
                        {
                            npc.frameCounter = 19 + (npc.localAI[3] / 3f) % 3;
                        }

                        if (npc.localAI[3] == 50)
                        {
                            npc.extraValue += Item.buyPrice(0, 1, 0, 0);
                            npc.moneyPing(npc.Center);
                        }

                        goto gohere;
                    }
                    else
                    {
                        if (npc.localAI[3] < 200)
                        {
                            //if (npc.frameCounter < 5)
                            //{
                            npc.frameCounter += 0.25f;
                            npc.frameCounter %= 5;
                            //if (npc.frameCounter >= 5 && npc.frameCounter < 8)
                            //	npc.frameCounter = 5 - npc.frameCounter;
                            //}
                        }

                        if (npc.localAI[3] >= 200 && npc.localAI[3] < 400)
                        {
                            npc.localAI[3]++;
                            //if (npc.frameCounter < 5)
                            //{
                            if (npc.frameCounter < 18)
                            {
                                npc.frameCounter = 18;
                            }

                            if (npc.frameCounter < 21)
                            {
                                npc.frameCounter += 0.25f;
                            }

                            if (npc.frameCounter > 18 && npc.localAI[3] > 215)
                            {
                                npc.frameCounter -= 0.25f;
                            }

                            if (npc.localAI[3] > 230)
                            {
                                npc.localAI[3] = 100;
                            }
                            //}
                        }
                        if (npc.localAI[3] >= 400)
                        {
                            npc.localAI[3]++;
                            npc.frameCounter = 21f * (((npc.localAI[3] - 400) / 100f));
                            if (npc.localAI[3] > 460)
                            {
                                npc.localAI[3] = 201;
                            }
                        }
                    }
                    npc.dontTakeDamage = false;
                }


                npc.ai[0] += 1f;
                Vector2 gohere    = new Vector2(P.Center.X, P.Center.Y - 220) + offsetype;
                float   thespeed  = 0.01f;
                float   friction  = 0.98f - phase * 0.04f;
                float   friction2 = 0.99f - phase * 0.0075f;
                themode   -= 1;
                npc.ai[1] += Main.rand.Next(0, 5);
                if (npc.ai[1] % 2000 > 850)
                {
                    if (System.Math.Abs(npc.ai[2]) < 300)
                    {
                        compressvargoal = 1;
                        int theammount = (npc.ai[2] > 0 ? 1 : -1) * (offsetype.X > 0 ? 1 : -1);
                        if (npc.ai[1] % 2000 < 1100)
                        {
                            gohere       = new Vector2(P.Center.X + (theammount * 800), P.Center.Y - 220);
                            npc.velocity = (npc.velocity + ((gohere - npc.Center) * thespeed)) * 0.98f;
                        }
                        else
                        {
                            if (phase < 1)
                            {
                                theclostestcrate = Vector2.Zero;
                            }

                            npc.velocity = new Vector2(-theammount * ((GetType() == typeof(Cratrogeddon)) ? 15 : 10), 0);
                            if (npc.ai[0] % 15 == 0)
                            {
                                List <Projectile> itz = Idglib.Shattershots(npc.Center, P.Center + new Vector2(0, P.Center.Y > npc.Center.Y ? 600 : -600), new Vector2(0, 0), ModContent.ProjectileType <GlowingCopperCoin>(), (int)(npc.damage * (10.00 / defaultdamage)), 10, 0, 1, true, 0, true, 100);
                            }
                            if (npc.ai[0] % 40 == 0)
                            {
                                List <Projectile> itz = Idglib.Shattershots(theclostestcrate, P.Center, new Vector2(0, 0), ModContent.ProjectileType <GlowingGoldCoin>(), (int)(npc.damage * (30.00 / defaultdamage)), 10, 0, 1, true, 0, true, 200);
                            }
                            if (((npc.ai[0] + 20) % 40 == 0) && Main.expertMode)
                            {
                                List <Projectile> itz      = Idglib.Shattershots(theclostestcrate, P.Center + new Vector2(0, P.Center.Y > theclostestcrate.Y ? 600 : -600), new Vector2(0, 0), ModContent.ProjectileType <GlowingSilverCoin>(), (int)(npc.damage * (20.00 / defaultdamage)), 10, 0, 1, true, 0, true, 200);
                                SGAprojectile     modeproj = itz[0].GetGlobalProjectile <SGAprojectile>();
                                //modeproj.splittingcoins = true;
                                //modeproj.splithere = P.Center;
                            }
                            if (phase < 4)
                            {
                                if (npc.ai[0] % 8 == 0)
                                {
                                    Idglib.Shattershots(npc.Center, npc.Center + new Vector2(-npc.velocity.X, 0), new Vector2(0, 0), ModContent.ProjectileType <GlowingSilverCoin>(), (int)(npc.damage * (20.00 / defaultdamage)), 25, 0, 1, true, 0, false, 40);
                                }
                            }
                            themode = 300;
                            if (offsetype.X >= 0)
                            {
                                npc.localAI[0] = 5;
                                if (npc.Center.X < P.Center.X - 700)
                                {
                                    npc.ai[2] = Math.Abs(npc.ai[2]);
                                }
                                if (npc.Center.X > P.Center.X + 700)
                                {
                                    npc.ai[2] = -Math.Abs(npc.ai[2]);
                                }
                            }
                            else
                            {
                                if (npc.Center.X < P.Center.X - 700)
                                {
                                    npc.ai[2] = -Math.Abs(npc.ai[2]);
                                }
                                if (npc.Center.X > P.Center.X + 700)
                                {
                                    npc.ai[2] = Math.Abs(npc.ai[2]);
                                }
                            }
                            //npc.ai[1]=1600+(2000-1600);
                            //}
                        }
                    }
                    else
                    {
                        Vector2 gogo = P.Center - npc.Center; gogo.Normalize(); gogo = gogo * (8 - phase * 1);
                        if (GetType() == typeof(Cratrogeddon))
                        {
                            gogo *= 1.25f;
                        }
                        npc.velocity    = gogo;
                        compressvargoal = 2;
                        npc.localAI[0]  = 5;
                    }
                }
                else
                {
                    npc.ai[2] = Main.rand.Next(-600, 600);
                    if (npc.ai[0] % 600 < 350)
                    {
                        npc.velocity    = (npc.velocity + (((gohere) - npc.Center) * thespeed)) * friction;
                        compressvargoal = 1;

                        switch (phase)
                        {
                        case 5:
                        {
                            if (npc.ai[0] % 30 == 0)
                            {
                                Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), ModContent.ProjectileType <GlowingCopperCoin>(), (int)(npc.damage * (10f / (float)defaultdamage)), 10, 0, 1, true, 0, true, 150);
                            }
                            break;
                        }

                        case 4:
                        {
                            if (npc.ai[0] % 10 == 0)
                            {
                                Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), ModContent.ProjectileType <GlowingSilverCoin>(), (int)(npc.damage * (20f / (float)defaultdamage)), 14, 0, 1, true, 0, true, 100);
                            }
                            break;
                        }

                        case 3:
                        {
                            if (npc.ai[0] % 3 == 0 && npc.ai[0] % 50 > 38)
                            {
                                Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), ModContent.ProjectileType <GlowingGoldCoin>(), (int)(npc.damage * (30f / (float)defaultdamage)), 16, 0, 1, true, 0, true, 90);
                            }
                            if (npc.ai[0] % 8 == 0 && Main.expertMode)
                            {
                                List <Projectile> itz = Idglib.Shattershots(npc.Center, npc.Center + new Vector2(0, -5), new Vector2(0, 0), ModContent.ProjectileType <GlowingSilverCoin>(), (int)(npc.damage * (20f / (float)defaultdamage)), 7, 360, 2, true, npc.ai[0] / 20, true, 300);
                            }
                            break;
                        }

                        case 2:
                        {
                            if (npc.ai[0] % 5 == 0)
                            {
                                Idglib.Shattershots(npc.Center, npc.Center + new Vector2((P.velocity.X * 4f) + Main.rand.NextFloat(-24f, 24f), -96f), Vector2.Zero, ModContent.ProjectileType <GlowingGoldCoinHoming>(), (int)(npc.damage * (30f / (float)defaultdamage)), Main.rand.NextFloat(6f, 10f), 0, 1, true, 0, true, 600);
                            }
                        }
                        break;
                        }

                        doCharge = -100000;
                    }
                    else
                    {
                        npc.localAI[0]  = 5;
                        compressvargoal = 0.4f;
                        Vector2 gogo = P.Center - npc.Center; gogo.Normalize(); gogo = gogo * (30 - phase * 2);

                        if (doCharge < -1000)
                        {
                            doCharge = 120;
                        }

                        if (doCharge > 0)
                        {
                            npc.ai[0] -= 1;
                            if (doCharge == 60)
                            {
                                if (npc.localAI[3] > 0)
                                {
                                    npc.localAI[3] = 400;
                                }


                                SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_DarkMageAttack, npc.Center);
                                if (sound != null)
                                {
                                    sound.Pitch = -0.25f;
                                }

                                for (float f = 0; f < MathHelper.TwoPi; f += MathHelper.TwoPi / 12f)
                                {
                                    Vector2 offset = f.ToRotationVector2();
                                    int     dust   = Dust.NewDust(npc.Center + (offset * 32f), 0, 0, DustID.GoldFlame);
                                    Main.dust[dust].scale     = 1.5f;
                                    Main.dust[dust].noGravity = true;
                                    Main.dust[dust].velocity  = f.ToRotationVector2() * 4f;
                                }
                            }

                            npc.velocity /= 1.5f;
                        }
                        else
                        {
                            if (GetType() == typeof(Cratrogeddon))
                            {
                                gogo *= 0.4f;
                            }

                            float tiev = (GetType() == typeof(Cratrogeddon)) ? npc.ai[0] % (50 + (phase * 3)) : npc.ai[0] % (25 + (phase * 10));

                            if (tiev < (GetType() == typeof(Cratrogeddon) ? 10 : 1))
                            {
                                npc.velocity = (npc.velocity + gogo);

                                if (npc.localAI[3] > 0)
                                {
                                    npc.localAI[3] = 201;
                                }

                                if (npc.velocity.Length() > 30)
                                {
                                    npc.velocity.Normalize();
                                    npc.velocity *= 30f;
                                }
                            }
                            npc.velocity = npc.velocity * friction2;
                        }
                    }
                }
            }

gohere:

            npc.defense = (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.WoodenCrate.ToString()))) * 5 +
                          (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.IronCrate.ToString()))) * 6 +
                          (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.GoldenCrate.ToString()))) * 6 +
                          (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.DungeonFishingCrate.ToString()))) * 10 +
                          (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.JungleFishingCrate.ToString()))) * 10 +
                          (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + EvilCrateType.ToString()))) * 10 +
                          (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.HallowedFishingCrate.ToString()))) * 10 +
                          NPC.CountNPCS(mod.NPCType("CratrosityCrateDankCrate")) * 10 +
                          (int)(NPC.CountNPCS(mod.NPCType("CratrosityCrate" + ItemID.FloatingIslandFishingCrate.ToString()))) * (30);
            npc.defense *= Main.expertMode ? 4 : 2;
            npc.defense += Main.expertMode ? 20 : 0;
            OrderOfTheCrates(P);
        }
        public virtual void OrderOfTheCrates(Player P)
        {
            if (firstTimeSetup)
            {
                for (int layer = 0; layer < phase; layer++)
                {
                    Cratesperlayer[layer] = 4 + (layer * 4);
                    List <CratrosityInstancedCrate> cratesInThisLayer = new List <CratrosityInstancedCrate>();

                    for (int i = 0; i < Cratesperlayer[layer]; i = i + 1)
                    {
                        int crateType = ItemID.WoodenCrate;
                        if (layer == 3)
                        {
                            crateType = ItemID.IronCrate;
                            if (npc.ai[3] > 300000 && i % 2 == 0)
                            {
                                crateType = ModContent.ItemType <HavocGear.Items.DankCrate>();
                            }
                            else if (npc.ai[3] > 100000 && i % 2 == 0)
                            {
                                crateType = ItemID.HallowedFishingCrate;
                            }
                            else
                            {
                                if (npc.ai[3] < -100000 && i % 2 == 0)
                                {
                                    crateType = EvilCrateType;
                                }
                            }
                        }
                        if (layer == 2)
                        {
                            crateType = (i % 2 == 0) ? ItemID.JungleFishingCrate : ItemID.DungeonFishingCrate;
                        }
                        if (layer == 1)
                        {
                            crateType = (i % 2 == 0) ? ItemID.HallowedFishingCrate : (EvilCrateType);
                        }
                        if (layer == 0)
                        {
                            crateType = ItemID.FloatingIslandFishingCrate;
                        }
                        cratesInThisLayer.Add(new CratrosityInstancedCrate(this, crateType, 8, layer));
                    }
                    cratesPerRing.Add(cratesInThisLayer);
                }
                firstTimeSetup = false;
            }


            nonaispin    = nonaispin + 1f;
            compressvar += (compressvargoal - compressvar) / 20;
            float themaxdist = 99999f;

            for (int layer = 0; layer < phase; layer++)
            {
                for (int index = 0; index < cratesPerRing[layer].Count; index++)
                {
                    CratrosityInstancedCrate crate = cratesPerRing[layer][index];

                    if (!crate.Update())
                    {
                        continue;
                    }

                    crate.crateAngle = (layer % 2 == 0 ? 1 : -1) * ((nonaispin * 0.01f) * (1f + layer / 3f)) + MathHelper.TwoPi * ((index / (float)cratesPerRing[layer].Count));
                    crate.crateDist  = compressvar * 20f + ((float)layer * 20f) * compressvar;
                    //Cratesangle[a, i] = (a % 2 == 0 ? 1 : -1) * ((nonaispin * 0.01f) * (1f + a / 3f)) + 2.0 * Math.PI * ((i / (double)Cratesperlayer[a]));
                    //Cratesdist[a, i] = compressvar * 20f + ((float)a * 20f) * compressvar;

                    float theexpand = 0f;

                    if (themode > 0)
                    {
                        theexpand = (((index / 1f) * (layer + 1f))) * (themode / 30f);
                    }

                    crate.crateVector += ((crate.crateDist * (new Vector2((float)Math.Cos(crate.crateAngle), (float)Math.Sin(crate.crateAngle))) + npc.Center) - crate.crateVector) / (theexpand + (Math.Max((((compressvar) - 1) * (2 + (layer * 1))), 1)));
                    //if (index)
                    //crate.crateVector += Main.rand.NextVector2Circular(32, 32);

                    float sinner  = npc.ai[0] + ((float)(index * 5) + (layer * 14));
                    float sinner2 = (float)(10f + (Math.Sin(sinner / 30f) * 7f));

                    if (compressvar > 1.01)
                    {
                        int[]   projtype   = { ModContent.ProjectileType <GlowingPlatinumCoin>(), ModContent.ProjectileType <GlowingPlatinumCoin>(), ModContent.ProjectileType <GlowingPlatinumCoin>(), ModContent.ProjectileType <GlowingGoldCoin>(), ModContent.ProjectileType <GlowingSilverCoin>(), ModContent.ProjectileType <GlowingCopperCoin>() };
                        int[]   projdamage = { 60, 50, 40, 30, 20, 10 };
                        float[] projspeed  = { 1f, 1f, 1f, 9f, 8f, 7f };
                        if (layer == phase - 1)
                        {
                            if (sinner2 < 4 && (npc.ai[0] + (index * 4)) % 30 == 0)
                            {
                                List <Projectile> itz = Idglib.Shattershots(crate.crateVector, P.position, new Vector2(P.width, P.height), projtype[layer + 1], (int)((double)npc.damage * ((double)projdamage[layer + 1] / (double)defaultdamage)), projspeed[layer + 1], 0, 1, true, 0, false, 110);
                                if (projtype[layer + 1] == ModContent.ProjectileType <GlowingPlatinumCoin>())
                                {
                                    itz[0].aiStyle = 18; IdgProjectile.AddOnHitBuff(itz[0].whoAmI, BuffID.ShadowFlame, 60 * 10);
                                }
                            }
                        }

                        crate.crateVector += ((P.Center - crate.crateVector) / (sinner2)) * ((Math.Max(compressvar - 1, 0) * 1));
                    }
                    float dist = (P.Center - crate.crateVector).Length();
                    if (dist < themaxdist)
                    {
                        themaxdist       = dist;
                        theclostestcrate = crate.crateVector;
                    }
                }
            }
        }
        public override void AI()
        {
            int num254 = (int)(npc.position.X + (float)(npc.width / 2)) / 16;
            int num255 = (int)(npc.position.Y + (float)(npc.height / 2)) / 16;

            npc.ai[0] = npc.ai[0] + 1;
            npc.ai[1] = 0;
            if (Main.tile[num254, num255 + 1] != null && Main.tile[num254, num255 + 1].liquid > 64)
            {
                npc.ai[1] = 1;
            }
            if (Main.tile[num254, num255 - 1] == null)
            {
                Main.tile[num254, num255 - 1] = new Tile();
            }
            if (Main.tile[num254, num255 + 1] == null)
            {
                Main.tile[num254, num255 + 1] = new Tile();
            }
            if (Main.tile[num254, num255 + 2] == null)
            {
                Main.tile[num254, num255 + 2] = new Tile();
            }
            num255 = (int)(npc.position.Y + (float)(npc.height)) / 16;
            if (Main.tile[num254, num255 + 1].active())
            {
                if (Main.tile[num254, num255 + 1].liquid < 64)
                {
                    npc.ai[1] = -1;
                }
            }

            if (npc.ai[1] == -1 && outofwater < 300)
            {
                npc.velocity = new Vector2(npc.velocity.X, npc.velocity.Y - Main.rand.Next(6, 15));
            }


            Player P = Main.player[npc.target];

            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(false);
                P = Main.player[npc.target];
                if (!P.active || P.dead)
                {
                    npc.spriteDirection = npc.velocity.X > 0 ? 1 : -1;
                }
            }
            else
            {
                Vector2 dista  = P.Center - npc.Center;
                Vector2 dista2 = P.Center - npc.Center;
                //Vector2 dista2=dista;
                dista2.Normalize();
                npc.velocity       += (dista2 * (npc.ai[1] == 1 ? 0.2f : 0.4f));
                npc.spriteDirection = dista2.X > 0 ? 1 : -1;
                if (outofwater < 300)
                {
                    outofwater += (npc.ai[1] == 0 ? 1 : 0) + ((Collision.CanHitLine(new Vector2(npc.Center.X, npc.Center.Y), 16, 32, new Vector2(P.Center.X, P.Center.Y), 16, 32)) ? 0 : 1);
                }
                if (npc.ai[1] == -1 && outofwater > 299 && dista.Y < -30f)
                {
                    npc.velocity = new Vector2(npc.velocity.X, npc.velocity.Y - Main.rand.Next(6, 15));
                }
                if (npc.ai[0] % 400 > 250 && npc.ai[0] % 60 == 0 && Collision.CanHitLine(new Vector2(npc.Center.X, npc.Center.Y), 4, 4, new Vector2(P.Center.X, P.Center.Y), 4, 4))
                {
                    List <Projectile> itz = Idglib.Shattershots(npc.Center, P.position, new Vector2(P.width, P.height), mod.ProjectileType("ThrownTrident"), 20, 8, 0, 1, true, 0, true, 400);
                    itz[0].damage /= 2;
                }
            }

            if (outofwater > 299)
            {
                outofwater += 1;
                if (outofwater == 300)
                {
                    Vector2 dista2 = P.Center - npc.Center;
                    npc.velocity = new Vector2(npc.velocity.X, dista2.Y > -100 ? 16f : -16f);
                }
                if (outofwater > 350)
                {
                    npc.ai[1] = 1;
                }
                if (outofwater > 500)
                {
                    outofwater = 0;
                }
                npc.noTileCollide = true;
            }
            else
            {
                npc.noTileCollide = false;
            }
            npc.velocity = npc.velocity * 0.98f;

            if (npc.velocity.Length() > 14)
            {
                npc.velocity.Normalize();
                npc.velocity = npc.velocity * 14;
            }
            //Main.NewText(""+outofwater,255,255,255);
            if (npc.ai[1] == 1)
            {
                npc.rotation = 0f;
            }
            if (npc.ai[1] == 0)
            {
                npc.velocity = new Vector2(npc.velocity.X, npc.velocity.Y + 1f);
                npc.rotation = (npc.velocity.Y * 0.03f) * npc.spriteDirection;
            }
            npc.noGravity = npc.ai[1] == 1 ? true : false;
        }
Example #21
0
        public override void AI()
        {
            LegsMethod();
            charge        = false;
            legdists      = 128;
            npc.direction = npc.velocity.X > 0 ? -1 : 1;
            P             = Main.player[npc.target];
            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(false);
                P = Main.player[npc.target];
                if (!P.active || P.dead)
                {
                    float speed = ((-10f));
                    npc.velocity = new Vector2(npc.velocity.X, npc.velocity.Y + speed);
                    npc.active   = false;
                }
            }
            else
            {
                if (SGAWorld.NightmareHardcore > 0)
                {
                    phase = 2;
                }
                npc.dontTakeDamage = false;
                bool sighttoplayer = (Collision.CanHitLine(new Vector2(npc.Center.X, npc.Center.Y), 6, 6, new Vector2(P.Center.X, P.Center.Y), 6, 6));
                bool underground   = (int)((double)((npc.position.Y + (float)npc.height) * 2f / 16f) - Main.worldSurface * 2.0) > 0;
                if (!underground)
                {
                    npc.dontTakeDamage = true;
                }
                npc.ai[3] -= 1;
                if (npc.ai[3] < 1)
                {
                    npc.ai[0] += 1;
                }

                Vector2 playerangledif = P.Center - npc.Center;
                float   playerdist     = playerangledif.Length();
                float   maxspeed       = 3f;
                if (Main.expertMode && !sighttoplayer)
                {
                    maxspeed += 3f;
                }

                float maxrotate = 0.05f;
                playerangledif.Normalize();

                if (npc.ai[0] < 1201)                //Standard Attacks
                {
                    if (phase == 0)
                    {
                        if (npc.life < npc.lifeMax * 0.75)
                        {
                            DoPhase(1);
                            return;
                        }
                    }

                    npc.ai[0] %= 1200;
                    if (npc.ai[0] % 1200 < 600)
                    {
                        if (npc.ai[0] == 10)
                        {
                            if (phase > 0)
                            {
                                npc.ai[0] = Main.rand.Next(50, 400);
                            }
                            npc.netUpdate = true;
                        }

                        npc.localAI[0] += 1f;
                        npc.localAI[1]  = P.Center.X;
                        npc.localAI[2]  = P.Center.Y;
                        if ((npc.ai[0] + 26) % (Main.expertMode ? 60 : 90) == 0)
                        {
                            Idglib.Shattershots(npc.Center + npc.rotation.ToRotationVector2() * 32, npc.Center + npc.rotation.ToRotationVector2() * 200, new Vector2(0, 0), mod.ProjectileType("SpiderVenom"), 15, 8, 35 + phase * 5, phase + 1, true, 0, true, 1600);
                            Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 102, 0.25f, -0.25f);
                        }
                        npc.rotation  = npc.rotation.AngleLerp((P.Center - npc.Center).ToRotation(), maxrotate);
                        npc.velocity += npc.rotation.ToRotationVector2() * 0.4f;
                        npc.velocity += playerangledif * 0.075f;
                        if (npc.velocity.Length() > maxspeed)
                        {
                            npc.velocity.Normalize(); npc.velocity *= maxspeed;
                        }
                    }
                    else
                    {
                        //Acid Spin Attack
                        if (npc.ai[0] % 1200 == 601)
                        {
                            npc.ai[0] += 1;
                            npc.ai[3]  = 60;
                            Main.PlaySound(SoundID.NPCHit, (int)npc.Center.X, (int)npc.Center.Y, 37, 0.50f, -0.25f);
                        }
                        if (npc.ai[0] % 1200 > 602)
                        {
                            float angle1; float angle2;
                            GetAngleDifferenceBlushiMagic(new Vector2(npc.localAI[1], npc.localAI[2]), out angle1, out angle2);
                            float rotSpeed = angle2 > angle1 ? 0.05f : -0.05f;
                            rotSpeed *= 1f + ((float)(angle2 - angle1) * 0.2f);

                            legdists = 72;

                            if (npc.ai[0] % 150 < 60)
                            {
                                npc.rotation += rotSpeed;
                                if (npc.ai[0] % (Main.expertMode ? 5 : 10) == 0 && npc.ai[3] < 1)
                                {
                                    int type = mod.ProjectileType("SpiderVenom");
                                    Idglib.Shattershots(npc.Center + npc.rotation.ToRotationVector2() * 32, npc.Center + npc.rotation.ToRotationVector2() * 200, new Vector2(0, 0), type, 15, 7, 35 + (phase * 15), 1 + phase, true, 0, true, 1600);
                                    Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 102, 0.25f, -0.25f);
                                }

                                if (npc.ai[0] % 150 == 61)
                                {
                                    npc.localAI[1] = P.Center.X;
                                    npc.localAI[2] = P.Center.Y;
                                }
                            }
                        }


                        npc.velocity *= 0.96f;
                    }
                    if (npc.ai[0] == 1195 && phase > 0)
                    {
                        npc.ai[0] = 2100;
                    }
                }                //Standard Attacks Over

                DoPhase(phase);


                if (sighttoplayer)
                {
                    if (npc.ai[2] > 1500)
                    {
                        npc.ai[2]     = 0;
                        npc.ai[0]     = 3000;
                        npc.netUpdate = true;
                    }

                    if (phase > 1 && npc.ai[0] < 3000)
                    {
                        npc.ai[2] += 1;
                    }
                }
            }
        }
        private void OnHit(NPC npc, Player player, int damage, float knockback, bool crit, Item item, Projectile projectile, bool isproj = false)
        {
            SGAPlayer moddedplayer = player.GetModPlayer <SGAPlayer>();

            if (moddedplayer.HasGucciGauntlet())
            {
                if (player.ownedLargeGems[0] && Main.rand.Next(0, 10) == 0)
                {
                    npc.AddBuff(BuffID.ShadowFlame, 60 * 15);
                }
            }

            if (moddedplayer.flaskBuff != default && ((projectile != null && projectile.melee) || (item != null && item.melee)))
            {
                if (Main.rand.Next(0, moddedplayer.flaskBuff.Chance) == 0)
                {
                    npc.AddBuff(moddedplayer.flaskBuff.Debuff, moddedplayer.flaskBuff.Period);
                    moddedplayer.flaskBuff.OnRealHit(player, projectile, npc, damage);
                }
            }

            if (item != null && npc.life - damage < 1 && npc.lifeMax > 50)
            {
                if (item.type == mod.ItemType("Powerjack"))
                {
                    player.HealEffect(25, false);
                    player.netLife   = true;
                    player.statLife += 25;
                    if (player.statLife > player.statLifeMax2)
                    {
                        player.statLife = player.statLifeMax2;
                    }
                    NetMessage.SendData(66, -1, -1, null, player.whoAmI, (float)25f, 0f, 0f, 0, 0, 0);
                }
            }

            if (isproj)
            {
                if (projectile.minion && moddedplayer.IDGset)
                {
                    if (npc.immune[projectile.owner] > 0)
                    {
                        npc.immune[projectile.owner] = ((int)(npc.immune[projectile.owner] * 0.75f));
                    }

                    moddedplayer.digiStacks = Math.Min(moddedplayer.digiStacksMax, moddedplayer.digiStacks + (int)Math.Max((float)projectile.damage, (float)damage));
                }

                if (projectile.type == ProjectileID.CultistBossLightningOrbArc)
                {
                    immunitetolightning = projectile.localNPCHitCooldown;
                }

                bool trapdamage = false;
                if (projectile != null && projectile.trap)
                {
                    trapdamage = true;
                }


                if (trapdamage)
                {
                    if (moddedplayer.JaggedWoodenSpike)
                    {
                        if (Main.rand.Next(0, 100) < 15)
                        {
                            npc.AddBuff(mod.BuffType("MassiveBleeding"), 60 * 5);
                        }
                    }
                }

                if (moddedplayer.Mangroveset && player.ownedProjectileCounts[mod.ProjectileType("MangroveOrb")] < 4)
                {
                    if (crit && projectile.thrown)
                    {
                        player.AddBuff(BuffID.DryadsWard, 60 * 5);

                        int newDamage = damage;
                        if (newDamage > 50)
                        {
                            newDamage = 50 + (int)Math.Pow((damage - 50), 0.75f);
                        }

                        List <Projectile> itz = Idglib.Shattershots(player.Center, player.Center + (player.Center - npc.Center), new Vector2(0, 0), mod.ProjectileType("MangroveOrb"), newDamage, 8f, 120, 2, false, 0, false, 400);
                        //itz[0].damage = 30;
                        itz[0].owner = player.whoAmI; itz[0].friendly = true; itz[0].hostile = false;
                        itz[1].owner = player.whoAmI; itz[1].friendly = true; itz[1].hostile = false;
                        Main.projectile[itz[0].whoAmI].netUpdate = true;
                        Main.projectile[itz[1].whoAmI].netUpdate = true;

                        IdgProjectile.AddOnHitBuff(itz[0].whoAmI, BuffID.DryadsWardDebuff, 60 * 5);
                        IdgProjectile.AddOnHitBuff(itz[1].whoAmI, BuffID.DryadsWardDebuff, 60 * 5);

                        if (Main.netMode == 2 && itz[0].whoAmI < 200)
                        {
                            NetMessage.SendData(27, -1, -1, null, itz[0].whoAmI, 0f, 0f, 0f, 0, 0, 0);
                        }
                    }
                }
            }

            SGAWorld.overalldamagedone = ((int)damage) + SGAWorld.overalldamagedone;

            if (item != null)
            {
                if (moddedplayer.FieryheartBuff > 0)
                {
                    if (!npc.buffImmune[BuffID.Daybreak] || moddedplayer.FieryheartBuff > 15)
                    {
                        IdgNPC.AddBuffBypass(npc.whoAmI, 189, 1 * (20 + (int)(player.SGAPly().ExpertiseCollectedTotal / 250f)));
                    }
                }
            }

            if (projectile != null)
            {
                if (moddedplayer.FieryheartBuff > 0 && projectile.owner == player.whoAmI && projectile.friendly)
                {
                    if (!npc.buffImmune[BuffID.Daybreak] || moddedplayer.FieryheartBuff > 15)
                    {
                        IdgNPC.AddBuffBypass(npc.whoAmI, 189, 1 * (20 + (int)(player.SGAPly().ExpertiseCollectedTotal / 250f)));
                    }
                }
                if ((moddedplayer.CirnoWings) && projectile.owner == player.whoAmI)
                {
                    if (isproj && (projectile.magic == true && Main.rand.Next(0, 20) == 0) || projectile.coldDamage)
                    {
                        npc.AddBuff(BuffID.Frostburn, 4 * 60);
                    }
                }
                if ((moddedplayer.glacialStone) && projectile.owner == player.whoAmI && projectile.melee)
                {
                    if (isproj && projectile.melee == true)
                    {
                        npc.AddBuff(BuffID.Frostburn, Main.rand.Next(1, 6) * 60);
                    }
                }
            }

            if (moddedplayer.Redmanastar > 0)
            {
                if (isproj && projectile.magic == true)
                {
                    int[] buffids = { BuffID.OnFire, mod.BuffType("ThermalBlaze"), BuffID.Daybreak };
                    if (projectile != null && Main.rand.Next(0, 100) < 5)
                    {
                        npc.AddBuff(buffids[moddedplayer.Redmanastar - 1], 4 * 60);
                    }
                    if (projectile != null && Main.rand.Next(0, 100) < 1)
                    {
                        npc.buffImmune[buffids[moddedplayer.Redmanastar - 1]] = false;
                    }
                }
            }

            if (moddedplayer.SerratedTooth == true)
            {
                if (damage > npc.defense * 5)
                {
                    npc.AddBuff(mod.BuffType("MassiveBleeding"), Math.Min((int)(1f + ((float)damage - (float)npc.defense * 5f) * 0.02f) * 60, 60 * 5));
                }
            }

            if (moddedplayer.Blazewyrmset)
            {
                if (crit && ((item != null && item.melee && item.pick + item.axe + item.hammer < 1)) || (projectile != null && projectile.melee && (player.heldProj == projectile.whoAmI || (projectile.modProjectile != null && (projectile.modProjectile is IShieldBashProjectile || projectile.modProjectile is ITrueMeleeProjectile)))))
                {
                    if (player.SGAPly().AddCooldownStack(12 * 60))
                    {
                        Main.PlaySound(SoundID.Item45, npc.Center);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, mod.ProjectileType("BoulderBlast"), damage * 3, knockback * 3f, player.whoAmI, 0f, 0f);
                    }
                }
            }

            if (moddedplayer.alkalescentHeart)
            {
                int[] maxcrit = { player.meleeCrit, player.rangedCrit, player.magicCrit, player.Throwing().thrownCrit };
                Array.Sort(maxcrit);
                Array.Reverse(maxcrit);
                if (crit || (projectile != null && projectile.minion && Main.rand.Next(0, 100) < maxcrit[0]))
                {
                    Point point = new Point(0, 0);
                    point.X = (!npc.HasBuff(BuffID.Poisoned) ? BuffID.Poisoned : (!npc.HasBuff(BuffID.Venom) ? BuffID.Venom : (!npc.HasBuff(ModContent.BuffType <AcidBurn>()) ? ModContent.BuffType <AcidBurn>() : -1)));
                    if (point.X > -1)
                    {
                        point.Y = (point.X == ModContent.BuffType <AcidBurn>() ? 45 : point.X == BuffID.Venom ? 200 : point.X == BuffID.Poisoned ? 300 : 0);
                        npc.AddBuff(point.X, point.Y);
                        //if (Main.rand.Next(0, 10) == 0)
                        //	player.AddBuff(point.X, point.Y/2);
                    }
                }
            }

            bool hasabuff = false;

            if (npc.HasBuff(BuffID.OnFire))
            {
                hasabuff = true;
            }
            for (int i = 0; i < SGAmod.otherimmunes.Length; i++)
            {
                if (npc.HasBuff(SGAmod.otherimmunes[i]))
                {
                    hasabuff = true;
                }
            }


            if (DosedInGas && hasabuff)
            {
                Combusted = 60 * 6;
                int buff = npc.FindBuffIndex(mod.BuffType("DosedInGas"));

                if ((isproj && Main.player[projectile.owner].GetModPlayer <SGAPlayer>().MVMBoost) || (item != null && player.GetModPlayer <SGAPlayer>().MVMBoost))
                {
                    int prog = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, Vector2.Zero.X, Vector2.Zero.Y, ProjectileID.GrenadeIII, 350, 5f, player.whoAmI);
                    Main.projectile[prog].thrown = false; Main.projectile[prog].ranged = false; Main.projectile[prog].timeLeft = 2; Main.projectile[prog].netUpdate = true;
                    IdgProjectile.Sync(prog);
                }


                if (buff > -1)
                {
                    npc.DelBuff(buff);
                    IdgNPC.AddBuffBypass(npc.whoAmI, BuffID.OnFire, 60 * 10);
                }
            }

            if (player != null && player.SGAPly().toxicity > 0 && npc.HasBuff(BuffID.Stinky))
            {
                if (Main.rand.Next(0, 50) == 0)
                {
                    SGAPlayer.SwearExplosion(npc.Center, player, (int)(damage * 0.5f));
                }
            }

            /*if (PinkyMinion>0)
             * {
             *      if ((npc.life-damage)<1 && ((projectile.penetrate<5 && projectile.penetrate >= 0) || projectile == null))
             *      {
             *              NPC[] findnpc = SGAUtils.ClosestEnemies(npc.Center, 1500, checkWalls: false, checkCanChase: false)?.ToArray();
             *              findnpc = findnpc != null ? findnpc.Where(testby => testby.type == ModContent.NPCType<NPCs.SPinkyTrue>()).ToArray() : null;
             *
             *              if (findnpc != null && findnpc.Count()>0 && findnpc[0].type == ModContent.NPCType<NPCs.SPinkyTrue>())
             *              Projectile.NewProjectile(npc.Center, Vector2.Normalize(findnpc[0].Center - npc.Center) * 10f, ModContent.ProjectileType<NPCs.PinkyMinionKilledProj>(), 500, 0);
             *      }
             * }*/
        }
Example #23
0
        public override void AI()
        {
            float num644         = 1f;
            bool  flag65         = false;
            bool  flag66         = false;
            bool  touchingground = false;

            npc.aiAction    = 0;
            npc.localAI[0] += npc.localAI[0] > -1 ? 1 : -1;
            int dustype = mod.DustType("MangroveDust");

            if (npc.localAI[0] > 0)
            {
                dustype = 184;
            }

            if (npc.ai[3] == 0f && npc.life > 0)
            {
                npc.ai[3] = (float)npc.lifeMax;

                if (Main.netMode != 1)
                {
                    int num664 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("Murk2"), 0, 0f, 0f, 0f, 0f, 255);
                    Main.npc[num664].ai[1]     = npc.whoAmI;
                    Main.npc[num664].netUpdate = true;
                    if (Main.netMode == 2 && num664 < 200)
                    {
                        NetMessage.SendData(23, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0);
                    }
                }
            }

            if (npc.localAI[3] == 0f && Main.netMode != 1)
            {
                npc.ai[0]      = -100f;
                npc.localAI[3] = 1f;
                npc.TargetClosest(true);
                npc.netUpdate = true;
            }
            if (Main.player[npc.target].dead)
            {
                npc.TargetClosest(true);
                if (Main.player[npc.target].dead)
                {
                    npc.timeLeft = 0;
                    if (Main.player[npc.target].Center.X < npc.Center.X)
                    {
                        npc.direction = 1;
                    }
                    else
                    {
                        npc.direction = -1;
                    }
                }
            }
            else
            {
                npc.timeLeft = 100;
            }

            if (!Main.player[npc.target].dead && npc.ai[2] >= 300f && npc.ai[1] < 5f && npc.velocity.Y == 0f)
            {
                npc.ai[2] = 0f;
                npc.ai[0] = 0f;
                npc.ai[1] = 5f;
                if (Main.netMode != 1)
                {
                    npc.TargetClosest(false);
                    Point   point5   = npc.Center.ToTileCoordinates();
                    Point   point6   = Main.player[npc.target].Center.ToTileCoordinates();
                    Vector2 vector65 = Main.player[npc.target].Center - npc.Center;


                    int  num645 = 10;
                    int  num646 = 0;
                    int  num647 = 7;
                    int  num648 = 0;
                    bool flag67 = false;
                    if (vector65.Length() > 2000f)
                    {
                        flag67 = true;
                        num648 = 100;
                    }
                    while (!flag67 && num648 < 100)
                    {
                        num648++;
                        int num649 = Main.rand.Next(point6.X - num645, point6.X + num645 + 1);
                        int num650 = Main.rand.Next(point6.Y - num645, point6.Y + 1);
                        if ((num650 < point6.Y - num647 || num650 > point6.Y + num647 || num649 < point6.X - num647 || num649 > point6.X + num647) && (num650 < point5.Y - num646 || num650 > point5.Y + num646 || num649 < point5.X - num646 || num649 > point5.X + num646) && !Main.tile[num649, num650].nactive())
                        {
                            int  num651 = num650;
                            int  num652 = 0;
                            bool flag68 = Main.tile[num649, num651].nactive() && Main.tileSolid[(int)Main.tile[num649, num651].type] && !Main.tileSolidTop[(int)Main.tile[num649, num651].type];
                            if (flag68)
                            {
                                num652 = 1;
                            }
                            else
                            {
                                while (num652 < 150 && num651 + num652 < Main.maxTilesY)
                                {
                                    int  num653 = num651 + num652;
                                    bool flag69 = Main.tile[num649, num653].nactive() && Main.tileSolid[(int)Main.tile[num649, num653].type] && !Main.tileSolidTop[(int)Main.tile[num649, num653].type];
                                    if (flag69)
                                    {
                                        num652--;
                                        break;
                                    }
                                    num652++;
                                }
                            }
                            num650 += num652;
                            bool flag70 = true;
                            if (flag70 && Main.tile[num649, num650].lava())
                            {
                                flag70 = false;
                            }
                            if (flag70 && !Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
                            {
                                flag70 = false;
                            }
                            if (flag70)
                            {
                                npc.localAI[1] = (float)(num649 * 16 + 8);
                                npc.localAI[2] = (float)(num650 * 16 + 16);
                                break;
                            }
                        }
                    }
                    if (num648 >= 100)
                    {
                        Vector2 bottom = Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].Bottom;
                        npc.localAI[1] = bottom.X;
                        npc.localAI[2] = bottom.Y;
                    }
                }
            }
            if (!Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
            {
                npc.ai[2] += 1f;
            }
            if (Math.Abs(npc.Top.Y - Main.player[npc.target].Bottom.Y) > 320f)
            {
                npc.ai[2] += 1f;
            }

            if (Main.netMode != 1)
            {
                bool flag80 = false;
                int  num70  = 0;
                num70 = num70 + 1;
                Vector2 vector65 = Main.player[npc.target].Center - npc.Center;
                bool    flag71   = false;
                bool    flag81   = true;

                if (npc.life < npc.lifeMax / 2 && Main.expertMode == true)
                {
                    npc.damage          = 200;
                    npc.defense         = 30;
                    npc.knockBackResist = 0.0f;
                    if (npc.life <= 1000)
                    {
                        flag80 = true;
                    }
                }
                else if (npc.life < npc.lifeMax / 2 && Main.expertMode == false)
                {
                    npc.damage  = 150;
                    npc.defense = 20;
                }

                if (npc.life <= npc.lifeMax / 5)
                {
                    if (flag81 == true)
                    {
                        flag71 = true;
                    }
                }

                if (flag71 == true)
                {
                    npc.defense = 10;
                    flag81      = false;
                    flag71      = false;
                    if (counter++ == 10)
                    {
                    }
                }

                /*if (!Main.player[npc.target].ZoneJungle)
                 * {
                 *  npc.defense += 75;
                 * }*/

                if (Main.expertMode == true && npc.life <= npc.lifeMax / 10)
                {
                    if (num70 >= 75)
                    {
                        npc.life += 5;
                        num70     = 0;
                    }
                }
                //if (!Main.player[npc.target].ZoneJungle)
                //npc.defense=100;
            }

            if (npc.ai[1] == 5f)
            {
                flag65       = true;
                npc.aiAction = 1;
                npc.ai[0]   += 1f;
                num644       = MathHelper.Clamp((60f - npc.ai[0]) / 60f, 0f, 1f);
                num644       = 0.5f + num644 * 0.5f;
                if (npc.ai[0] >= 60f)
                {
                    flag66 = true;
                }

                /* if (npc.ai[0] == 60f)
                 * {
                 *  Gore.NewGore(npc.Center + new Vector2(-40f, (float)(-(float)npc.height / 2)), npc.velocity, 734, 1f);
                 * } */
                if (npc.ai[0] >= 60f && Main.netMode != 1)
                {
                    npc.Bottom    = new Vector2(npc.localAI[1], npc.localAI[2]);
                    npc.ai[1]     = 6f;
                    npc.ai[0]     = 0f;
                    npc.netUpdate = true;
                }
                if (Main.netMode == 1 && npc.ai[0] >= 120f)
                {
                    npc.ai[1] = 6f;
                    npc.ai[0] = 0f;
                }
                if (!flag66)
                {
                    for (int num654 = 0; num654 < 10; num654++)
                    {
                        int num655 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, dustype, npc.velocity.X, npc.velocity.Y, 100, new Color(30, 30, 30, 20), 2f);
                        Main.dust[num655].noGravity = true;
                        Main.dust[num655].velocity *= 0.5f;
                    }
                }
            }
            else if (npc.ai[1] == 6f)
            {
                flag65       = true;
                npc.aiAction = 0;
                npc.ai[0]   += 1f;
                num644       = MathHelper.Clamp(npc.ai[0] / 30f, 0f, 1f);
                num644       = 0.5f + num644 * 0.5f;
                if (npc.ai[0] >= 30f && Main.netMode != 1)
                {
                    npc.ai[1]     = 0f;
                    npc.ai[0]     = 0f;
                    npc.netUpdate = true;
                    npc.TargetClosest(true);
                }
                if (Main.netMode == 1 && npc.ai[0] >= 60f)
                {
                    npc.ai[1] = 0f;
                    npc.ai[0] = 0f;
                    npc.TargetClosest(true);
                }
                for (int num656 = 0; num656 < 10; num656++)
                {
                    int num657 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, dustype, npc.velocity.X, npc.velocity.Y, 100, new Color(30, 30, 30, 20), 2f);
                    Main.dust[num657].noGravity = true;
                    Main.dust[num657].velocity *= 2f;
                }
            }

            npc.dontTakeDamage = ((npc.hide = flag66) || (NPC.CountNPCS(mod.NPCType("BossFlyMiniboss1")) > 0 && Main.hardMode));
            if (Main.hardMode)
            {
                npc.GivenName = "Murk: Lord of the flies";
            }

            if (npc.velocity.Y == 0f)
            {
                touchingground = true;
                npc.velocity.X = npc.velocity.X * 0.8f;
                if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1)
                {
                    npc.velocity.X = 0f;
                }
                if (!flag65)
                {
                    if (npc.life < (npc.lifeMax * 0.75) && npc.localAI[0] > -600)
                    {
                        npc.ai[0] = -100f;
                        npc.ai[2] = 0f;
                        if (npc.localAI[0] > 0)
                        {
                            npc.localAI[0] = -1;
                        }
                        //npc.dontTakeDamage=true;
                        npc.defense *= 2;

                        if ((-npc.localAI[0]) % 15 == 0)
                        {
                            npc.TargetClosest(true);
                            npc.netUpdate = true;
                            Player            target = Main.player[npc.target];
                            List <Projectile> itz2   = Idglib.Shattershots(npc.Center, target.position, new Vector2(target.width / 2, target.height / 2), ProjectileID.HornetStinger, 15, 15f, 0, 1, true, 0f, false, 300);
                            Main.PlaySound(SoundID.Item42, npc.Center);

                            for (int num656 = 0; num656 < 15; num656++)
                            {
                                int num657 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 184, itz2[0].velocity.X, itz2[0].velocity.Y, 100, new Color(80, 80, 80, 100), 1.5f);
                                Main.dust[num657].noGravity = true;

                                Main.dust[num657].velocity = (new Vector2(itz2[0].velocity.X, itz2[0].velocity.Y) * 2) * ((float)num656 / 15);
                            }
                        }

                        for (int xx = 0; xx < 5; xx++)
                        {
                            int num657 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, mod.DustType("MangroveDust"), npc.velocity.X, npc.velocity.Y, 100, new Color(30, 30, 30, 20), 1f);
                            Main.dust[num657].noGravity = true;
                            Main.dust[num657].velocity *= 2f;
                        }
                    }

                    npc.ai[0] += 2f;
                    if ((double)npc.life < (double)npc.lifeMax * 0.8)
                    {
                        npc.ai[0] += 1f;
                    }
                    if ((double)npc.life < (double)npc.lifeMax * 0.6)
                    {
                        npc.ai[0] += 1f;
                    }
                    if ((double)npc.life < (double)npc.lifeMax * 0.4)
                    {
                        npc.ai[0] += 2f;
                    }
                    if ((double)npc.life < (double)npc.lifeMax * 0.2)
                    {
                        npc.ai[0] += 3f;
                    }
                    if ((double)npc.life < (double)npc.lifeMax * 0.1)
                    {
                        npc.ai[0] += 4f;
                    }
                    if (npc.ai[0] >= 0f)
                    {
                        npc.netUpdate = true;
                        npc.TargetClosest(true);
                        if (npc.ai[1] == 3f)
                        {
                            npc.velocity.Y = -13;
                            npc.velocity.X = npc.velocity.X + 3.5f * (float)npc.direction;
                            npc.ai[0]      = -200f;
                            npc.ai[1]      = 0f;
                        }
                        else if (npc.ai[1] == 2f)
                        {
                            npc.velocity.Y = -6f;
                            npc.velocity.X = npc.velocity.X + (npc.localAI[0] < 0 ? 10f : 4.5f) * (float)npc.direction;
                            npc.ai[0]      = -120f;
                            npc.ai[1]     += 1f;
                        }
                        else
                        {
                            npc.velocity.Y = -8f;
                            float distz = Main.player[npc.target].Center.Y - npc.Center.Y;
                            if (distz < -96)
                            {
                                npc.velocity.Y += (distz - 100) / 60f;
                            }
                            npc.velocity.X = npc.velocity.X + 4f * (float)npc.direction;
                            npc.ai[0]      = -120f;
                            npc.ai[1]     += 1f;
                        }
                    }
                    else if (npc.ai[0] >= -30f)
                    {
                        npc.aiAction = 1;
                    }
                }
            }
            else if (npc.target < 255 && ((npc.direction == 1 && npc.velocity.X < 3f) || (npc.direction == -1 && npc.velocity.X > -3f)))
            {
                if ((npc.direction == -1 && (double)npc.velocity.X < 0.1) || (npc.direction == 1 && (double)npc.velocity.X > -0.1))
                {
                    npc.velocity.X = npc.velocity.X + 0.2f * (float)npc.direction;
                }
                else
                {
                    npc.velocity.X = npc.velocity.X * 0.93f;
                }
            }



            if (Math.Abs(npc.velocity.Y) < 8f && npc.ai[1] == 0 && npc.localAI[0] % 2 == 0 && !touchingground && npc.localAI[0] < 0)
            {
                double            angle = ((double)(npc.localAI[0] / 13f)) + 2.0 * Math.PI;
                List <Projectile> itz   = Idglib.Shattershots(npc.Center, npc.Center, new Vector2(0, 16), ProjectileID.Stinger, 15, 5f, 0, 1, true, (float)angle, true, 300);
                itz = Idglib.Shattershots(npc.Center, npc.Center, new Vector2(0, 16), ProjectileID.Stinger, 15, 5f, 0, 1, true, (float)-angle, true, 300);
            }
            if (npc.localAI[0] < -3000)
            {
                npc.localAI[0] = 5;
            }

            //Vector2 vector3 = Collision.WaterCollision(npc.position, new Vector2(0,16), npc.width, npc.height, false, false, false);
            if (npc.wet)
            {
                npc.life = (int)MathHelper.Clamp(npc.life + 1, 0, npc.lifeMax);
            }


            int num658 = Dust.NewDust(npc.position, npc.width, npc.height, dustype, npc.velocity.X, npc.velocity.Y, 100, new Color(30, 30, 30, 20), npc.scale * 1.2f);

            Main.dust[num658].noGravity = true;
            Main.dust[num658].velocity *= 0.5f;
            if (npc.life > 0)
            {
                float num659 = (float)npc.life / (float)npc.lifeMax;
                num659  = num659 * 0.5f + 0.75f;
                num659 *= num644;
                if (num659 != npc.scale)
                {
                    npc.position.X = npc.position.X + (float)(npc.width / 2);
                    npc.position.Y = npc.position.Y + (float)npc.height;
                    npc.scale      = num659;
                    npc.width      = (int)(98f * npc.scale);
                    npc.height     = (int)(92f * npc.scale);
                    npc.position.X = npc.position.X - (float)(npc.width / 2);
                    npc.position.Y = npc.position.Y - (float)npc.height;
                }
                if (Main.netMode != 1)
                {
                    int num660 = (int)((double)npc.lifeMax * 0.04);
                    if ((float)(npc.life + num660) < npc.ai[3])
                    {
                        npc.ai[3] = (float)npc.life;
                        int num661 = Main.rand.Next(1, 4);
                        for (int num662 = 0; num662 < num661; num662++)
                        {
                            int x      = (int)(npc.position.X + (float)Main.rand.Next(npc.width - 32));
                            int y      = (int)(npc.position.Y + (float)Main.rand.Next(npc.height - 32));
                            int num663 = NPCID.JungleSlime;
                            if (Main.hardMode)
                            {
                                num663 = NPCID.SpikedJungleSlime;
                            }
                            if (Main.rand.NextBool())
                            {
                                num663 = mod.NPCType("SwampSlime");
                            }
                            if (npc.localAI[0] < 0 && Main.expertMode)
                            {
                                if (Main.rand.Next(0, 100) < 20)
                                {
                                    num663 = NPCID.SpikedJungleSlime;
                                }
                                if (num663 == NPCID.JungleSlime || num663 == mod.NPCType("SwampSlime"))
                                {
                                    num663 = mod.NPCType("BossFly3");
                                }
                            }

                            int num664 = NPC.NewNPC(x, y, num663, 0, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num664].SetDefaults(num663, -1f);
                            Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f;
                            Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f;
                            Main.npc[num664].ai[0]      = (float)(-1000 * Main.rand.Next(3));
                            Main.npc[num664].ai[1]      = 0f;
                            if (num663 == mod.NPCType("BossFly3"))
                            {
                                Main.npc[num664].ai[1] = npc.whoAmI;
                            }

                            Main.npc[num664].netUpdate = true;
                            if (Main.netMode == 2 && num664 < 200)
                            {
                                NetMessage.SendData(23, -1, -1, null, num664, 0f, 0f, 0f, 0, 0, 0);
                            }
                        }
                        return;
                    }
                }
            }
        }
        public override void AI()
        {
            npc.ai[3] = SGAWorld.downedCaliburnGuardians;
            appear    = Math.Max(appear - 0.03f, appear);
            trailingeffect();
            npc.knockBackResist = 0.85f;
            nohit += 1;

            Player P = Main.player[npc.target];

            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(false);
                P = Main.player[npc.target];
                if (!P.active || P.dead)
                {
                    npc.active = false;
                }
            }
            else
            {
                npc.dontTakeDamage = P.GetModPlayer <SGAPlayer>().DankShrineZone != true;
                if (npc.ai[1] < 1)
                {
                    npc.spriteDirection = npc.velocity.X > 0 ? -1 : 1;
                    npc.ai[0]          += 1;
                }

                float floattime = (90 - (npc.ai[3] * 10));

                Vector2 theside = new Vector2(P.Center.X - npc.Center.X > 0 ? -200 : 200, 0);
                if (npc.ai[0] % 600 < 280 && !(npc.ai[0] % 1150 > 700))
                {
                    theside  = new Vector2(P.Center.X - npc.Center.X > 0 ? -120 : 120, 0);
                    theside *= 0.5f + (float)Math.Cos(-npc.ai[0] / (floattime / 4f)) * 0.20f;
                }

                Vector2 itt      = ((P.Center + theside) - npc.Center);
                float   locspeed = 0.25f;

                if (npc.ai[1] > 0)
                {
                    DeployTraps();
                    return;
                }

                if (npc.ai[0] % 1150 > 800)
                {
                    DropBolders();
                }
                else
                {
                    if (npc.ai[0] % 600 > 350)
                    {
                        nohit = -10;
                        if (Main.expertMode)
                        {
                            npc.knockBackResist = 0f;
                        }
                        npc.damage   = (int)npc.defDamage * 3;
                        itt          = itt = (P.Center - npc.Center + new Vector2(0, -8));
                        npc.rotation = npc.rotation + (0.65f * npc.spriteDirection);

                        if (npc.ai[0] % (70) == 0)
                        {
                            if (npc.ai[3] > 0)
                            {
                                Idglib.Shattershots(npc.Center, npc.Center - npc.velocity * 26f, new Vector2(P.width, P.height), ProjectileID.CrystalShard, 10, npc.ai[3] * 8f, npc.ai[3] * 60, 8 + (int)npc.ai[3] * 8, true, 0, false, 200);
                            }
                            if (npc.ai[3] > 0)
                            {
                                Idglib.Shattershots(npc.Center, npc.Center + npc.velocity * 26f, new Vector2(P.width, P.height), ProjectileID.EnchantedBeam, 20, 6f, 30, (int)npc.ai[3], true, 0, false, 200);
                            }

                            npc.velocity = npc.velocity * 0.96f;
                            npc.velocity = npc.velocity + (itt * locspeed);
                            itt.Normalize();
                            npc.velocity = itt * 24f;
                            appear       = 0.9f;
                        }
                        locspeed = 0.15f;
                    }
                    else
                    {
                        npc.damage = (int)npc.defDamage;
                        if (npc.ai[0] % 300 < 60)
                        {
                            locspeed     = 2.5f;
                            npc.velocity = npc.velocity * 0.92f;
                        }
                        else
                        {
                            if (npc.ai[0] > 1600 && Main.expertMode)
                            {
                                npc.ai[1] = 1;
                            }
                            npc.velocity = npc.velocity * 0.96f;

                            if (npc.ai[0] % 90 - (npc.ai[3] * 10) == 0)
                            {
                                Idglib.Shattershots(npc.Center, P.Center + new Vector2((P.Center.X - npc.Center.X) > 0 ? 200 : -200, 0), new Vector2(P.width, P.height), ProjectileID.DiamondBolt, 15, 5, npc.ai[3] * 5, 1 + (int)npc.ai[3], true, 0, false, 200);
                            }
                        }

                        npc.rotation = (float)npc.velocity.X * 0.09f;
                        locspeed     = 0.5f;
                    }

                    if (npc.ai[0] % 600 > 350 && npc.ai[0] % 300 > 60)
                    {
                        npc.velocity = npc.velocity * 0.96f;
                    }

                    itt.Normalize();
                    npc.velocity = npc.velocity + (itt * locspeed);
                }
            }
        }
Example #25
0
        public override void AI()
        {
            Player P = Main.player[npc.target];

            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active || !Main.dayTime)
            {
                npc.TargetClosest(false);
                P = Main.player[npc.target];
                if (!P.active || P.dead || !Main.dayTime)
                {
                    float speed = ((-10f));
                    npc.velocity = new Vector2(npc.velocity.X, npc.velocity.Y + speed);
                    npc.active   = false;
                }
            }
            else
            {
                if (Main.expertMode)
                {
                    if (npc.life < npc.lifeMax * 0.20 && npc.ai[3] == 0)
                    {
                        npc.ai[3] = 1;
                        NPC.SpawnOnPlayer(P.whoAmI, mod.NPCType("CirnoIceFairy"));
                        NPC.SpawnOnPlayer(P.whoAmI, mod.NPCType("CirnoIceFairy2"));
                    }
                    npc.defense = 20 + (NPC.CountNPCS(mod.NPCType("CirnoIceFairy")) * 50) + (NPC.CountNPCS(mod.NPCType("CirnoIceFairy2")) * 50);
                }

                bool snow = P.ZoneSnow;
                npc.dontTakeDamage  = (!snow);
                npc.netUpdate       = true;
                npc.timeLeft        = 99999;
                bobbing             = bobbing + 1;
                npc.spriteDirection = -npc.direction;
                aicounter           = aicounter + 1;
                Vector2 dist = P.Center - npc.Center;

                if (card > 0)
                {
                    if (nightmaremode)
                    {
                        if (nightmareprog < card * 400)
                        {
                            nightmareprog += 1;
                        }

                        /*if (nightmareprog == 1)
                         * {
                         *
                         *
                         * }*/
                        if (SGAWorld.CirnoBlizzard < card * 100 && nightmareprog % 3 == 0)
                        {
                            SGAWorld.CirnoBlizzard += 1;
                        }
                        ScreenShaderData shad = Filters.Scene["SGAmod:CirnoBlizzard"].GetShader();
                        shad.UseColor(Color.Lerp(Color.Blue, Color.Turquoise, 0.5f + (float)Math.Sin(Main.GlobalTime)));
                        Main.raining         = true;
                        Main.windSpeed       = MathHelper.Clamp(Main.windSpeed + Math.Sign((P.Center.X - npc.Center.X)) * (-0.002f / 3f), -0.4f, 0.4f);
                        Main.maxRaining      = Math.Min(Main.maxRaining + 0.002f, 1f);
                        Main.rainTime        = 5;
                        Main.UseStormEffects = true;


                        nightmareprog = Math.Min(nightmareprog, 2000);


                        if (nightmareprog > 100)
                        {
                            for (int i = 0; i < Main.maxPlayers; i += 1)
                            {
                                if (Main.player[i].active && !Main.player[i].dead)
                                {
                                    Main.player[i].AddBuff(BuffID.WindPushed, 2);
                                }
                            }
                        }
                        if (nightmareprog > 500)
                        {
                            ScreenObstruction.screenObstruction = Math.Min((nightmareprog - 500) / 600f, 0.5f);
                            for (int i = 0; i < Main.maxPlayers; i += 1)
                            {
                                if (Main.player[i].active && !Main.player[i].dead)
                                {
                                    //if (card>3)
                                    //Main.player[i].AddBuff(BuffID.Obstructed, (int)((Main.maxRaining-0.5f)*120f));
                                    Main.player[i].AddBuff(BuffID.Darkness, (int)((Main.maxRaining - 0.5f) * 60f));
                                }
                            }
                        }
                    }
                }

                if (aistate == 3)
                {
                    if (aicounter > 49)
                    {
                        aistate = 0;
                    }
                }

                if (aistate == 2)
                {
                    spellcard(card, aicounter, P);
                    float floater = (float)(Math.Sin(bobbing / 14f) * 4f);
                    npc.direction = -1;
                    if (dist.X > 0)
                    {
                        npc.direction = 1;
                    }
                    npc.velocity = new Vector2(((P.Center.X - ((npc.Center.X))) / 150), ((P.Center.Y - ((npc.Center.Y + 120))) / 110) + floater);
                    if (npc.life < npc.lifeMax * damagetospellcard)
                    {
                        aistate           = 0;
                        aicounter         = 0;
                        framevar          = 0;
                        stateaction       = 0;
                        frameid           = 0;
                        attacktype        = 0;
                        damagetospellcard = damagetospellcard - 0.15f;
                    }
                }



                if (aistate == 3)
                {
                    if (aicounter > 15)
                    {
                        int  dustType  = 113;      //Main.rand.Next(139, 143);
                        int  dustIndex = Dust.NewDust(npc.Center + new Vector2(-16, -16), 32, 32, dustType);
                        Dust dust      = Main.dust[dustIndex];
                        dust.velocity.X = dust.velocity.X - npc.velocity.X;
                        dust.velocity.Y = dust.velocity.Y - npc.velocity.Y;
                        dust.scale     *= 3f + Main.rand.Next(-30, 31) * 0.01f;
                        dust.fadeIn     = 0f;
                        dust.noGravity  = true;
                        //dust.color=Main.hslToRgb((float)(npc.ai[0]/300)%1, 1f, 0.9f);

                        npc.velocity = npc.velocity + (npc.DirectionTo(P.Center) * 0.7f);
                        if (npc.velocity.Length() > 14)
                        {
                            npc.velocity.Normalize();
                            npc.velocity = npc.velocity * 14;
                        }
                        if (npc.velocity.X > 0)
                        {
                            npc.rotation  = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X);
                            npc.direction = 1;
                        }
                        else
                        {
                            npc.rotation  = (float)Math.Atan2(-npc.velocity.Y, -npc.velocity.X);
                            npc.direction = -1;
                        }
                        if (dist.Length() > 180)
                        {
                            aicounter = aicounter - 1;
                        }
                        if (bobbing > 220)
                        {
                            float aimer = Main.rand.Next(-1000, 1000);
                            if (bobbing % 25 == 0)
                            {
                                List <Projectile> bolts = Idglib.Shattershots(new Vector2(npc.Center.X, npc.Center.Y), P.position, new Vector2(P.width, P.height), ProjectileID.IceBolt, 20, (float)Main.rand.Next(60, 80) / 5, 25, 3, true, (float)(aimer / 8000), false, 60);
                            }
                        }
                        if (aicounter > 220)
                        {
                            aistate     = 0;
                            aicounter   = 40;
                            framevar    = 0;
                            stateaction = 0;
                            frameid     = 0;
                            attacktype  = 0;
                        }
                    }
                    else
                    {
                        bobbing      = 0;
                        npc.velocity = npc.velocity * 0.9f;
                    }
                }
                else
                {
                    npc.rotation = (float)0f;
                }


                if (aistate == 0)
                {
                    if (npc.life < npc.lifeMax * damagetospellcard)
                    {
                        aistate           = 2;
                        aicounter         = 0;
                        stateaction       = 0;
                        attacktype        = 0;
                        card              = card + 1;
                        damagetospellcard = damagetospellcard - 0.20f;
                    }

                    if (aicounter > 90 && Main.rand.Next(-((int)15000 + npc.life / 2), (int)dist.Length()) > 100)
                    {
                        aicounter   = 0;
                        aistate     = 3;
                        framevar    = 0;
                        stateaction = 2;
                        frameid     = 14;
                    }
                    if (aicounter > 140 || (aicounter > 100 && card == 3))
                    {
//if (!Collision.CheckAABBvLineCollision(P.Center-new Vector2(8,8), new Vector2(16,16), npc.Center+new Vector2(npc.Center.X+(npc.direction*64),0), P.Center, 10, ref point))
//
                        aicounter   = 0;
                        aistate     = 1;
                        framevar    = 0;
                        stateaction = 1;
                        frameid     = 6;
                        attacktype  = (int)Main.rand.Next(0, 2);
                    }

//}
                    float floater = (float)(Math.Sin(bobbing / 17f) * 9f);
                    if (npc.Center.X < P.Center.X)
                    {
                        npc.direction = 1;
                        npc.velocity  = new Vector2(2, ((P.Center.Y - npc.Center.Y) / 12) + floater);
                    }
                    else
                    {
                        npc.velocity  = new Vector2(-2, ((P.Center.Y - npc.Center.Y) / 12) + floater);
                        npc.direction = -1;
                    }

                    npc.velocity.Normalize();
                    npc.velocity = npc.velocity * 2;
                }
                if (aistate == 1 || aistate == 10)
                {
                    npc.velocity = new Vector2(0, 0);

                    if (aistate == 10)
                    {
                        if (aicounter < 5)
                        {
                            mixup = Main.rand.Next(0, 3);
                        }
                        if (aicounter > 19 && aicounter < 76 && aicounter % 3 == 0 && mixup == 0)
                        {
                            float aimer = Main.rand.Next(0, 0);
                            Idglib.Shattershots(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), P.position, new Vector2(P.width, P.height), 348, 10, (float)26, 0, 1, true, (float)(aimer / 8000), false, Main.rand.Next(100, 120));
                        }

                        if (mixup == 2)
                        {
                            if (aicounter == 19)
                            {
                                for (int num315 = 0; num315 < 60; num315 = num315 + 1)
                                {
                                    int dust = Dust.NewDust(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), 0, 0, 113, Main.rand.Next(-5, 5), Main.rand.Next(-5, 5), 25, Main.hslToRgb(0.6f, 0.9f, 1f), 3f);
                                    Main.dust[dust].noGravity = true;
                                    //Main.dust[dust].velocity *= 1.8f;
                                    //Main.dust[dust].velocity.Y -= 0.5f;
                                    Main.playerDrawDust.Add(dust);
                                }
                            }
                            if (aicounter > 9 && aicounter < 66 && aicounter % 2 == 0)
                            {
                                float aimer = Main.rand.Next(0, 0);
                                Idglib.Shattershots(P.position + new Vector2(Main.rand.Next(-100, 100), P.Center.Y + 200), P.position + new Vector2(Main.rand.Next(-100, 100), P.Center.Y - 500), new Vector2(P.width, P.height), ProjectileID.IcewaterSpit, 20, (float)23, 0, 1, true, 0, false, Main.rand.Next(270, 370));
                            }
                        }

                        if (aicounter == 19 && mixup == 1)
                        {
                            List <Projectile> itz = Idglib.Shattershots(npc.Center - new Vector2(0, 30), npc.Center - new Vector2(-npc.direction * 20, 30), new Vector2(0, 0), mod.ProjectileType("SnowCloud"), 40, 5f, 0, 1, true, 0, false, 500);
                            itz[0].velocity = itz[0].velocity + new Vector2(0, -6);
                        }
                    }
                    if (aistate == 1)
                    {
                        if (card == 0 || card > 1)
                        {
                            if (attacktype == 0)
                            {
                                if (aicounter == 20)
                                {
                                    if (Main.netMode != 1)
                                    {
                                        int proj2 = Projectile.NewProjectile(0, npc.Center.Y, P.Center.X, P.Center.Y, 464, 40, 4, 0);
                                        Main.projectile[proj2].friendly = false;
                                        Main.projectile[proj2].hostile  = true;
//Main.projectile[proj2].timeLeft=70;
                                        Main.projectile[proj2].position = new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y);
                                    }
                                }
                            }
                            if (attacktype == 1)
                            {
                                if (aicounter > 19 && aicounter < 46 && aicounter % 3 == 0)
                                {
//Shattershots(new Vector2(npc.Center.X+(npc.direction*48),npc.Center.Y),P.position,new Vector2(P.width,P.height),118,15,Main.rand.Next(6,18),0,1,true,Main.rand.Next(-4,4));
                                    float             aimer = Main.rand.Next(-1000, 1000);
                                    List <Projectile> bolts = Idglib.Shattershots(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), P.position, new Vector2(P.width, P.height), mod.ProjectileType("CirnoBolt"), 80, (float)Main.rand.Next(60, 80) / 10f, 0, 1, true, (float)(aimer / 8000), false, 200);
                                    CirnoBolt         Cbolt = bolts[0].modProjectile as CirnoBolt;
                                    Cbolt.homing       = 0.04f;
                                    bolts[0].netUpdate = true;

//Shattershots(npc.position,P.position,new Vector2(P.width,P.height),83,20,12,40,2,true,0);
                                }
                            }
                        }

                        if (card == 1 || card > 1)
                        {
                            if (attacktype == 0)
                            {
                                if (aicounter == 20)
                                {
                                    Idglib.Shattershots(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), P.position, new Vector2(P.width, P.height), ProjectileID.EnchantedBeam, 30, (float)Main.rand.Next(60, 80) / 4, 30, 2, true, 0, false, 150);
                                }
                            }

                            if (attacktype == 1)
                            {
                                if (aicounter > 19 && aicounter < 79 && aicounter % 3 == 0)
                                {
//Shattershots(new Vector2(npc.Center.X+(npc.direction*48),npc.Center.Y),P.position,new Vector2(P.width,P.height),Projectile.IceBolt,15,Main.rand.Next(6,18),0,1,true,Main.rand.Next(-4,4));
                                    float aimer = Main.rand.Next(-1000, 1000);
                                    Idglib.Shattershots(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), P.position, new Vector2(P.width, P.height), 174, 25, (float)Main.rand.Next(60, 80) / 3, 0, 1, true, (float)(aimer / 8000) + (float)(aicounter - 50), true, 200);
                                    Idglib.Shattershots(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), P.position, new Vector2(P.width, P.height), 174, 25, (float)Main.rand.Next(60, 80) / 3, 0, 1, true, ((float)(aimer / 8000) + (float)(aicounter - 50)) + 90, true, 200);
//Shattershots(npc.position,P.position,new Vector2(P.width,P.height),83,20,12,40,2,true,0);
                                }
                            }
                        }
                    }


                    if (aicounter > 80)
                    {
                        frameid = 12;
                    }
                    if (aicounter == 90 || (aicounter == 40 && card == 3 && aistate != 10))
                    {
                        if (aistate == 10)
                        {
                            aistate = 2;
                        }
                        else
                        {
                            aistate = 0;
                        }
                        framevar    = 0;
                        stateaction = 0;
                        frameid     = 0;
                        aicounter   = 0;
                    }
                }
            }
        }
Example #26
0
        private void spellcard(int mycardid, int counter, Player P)
        {
            if (counter > 50)
            {
                if (mycardid == 1)
                {
                    if (counter % 6 == 0)
                    {
                        Vector2 vis   = new Vector2(P.Center.X + Main.rand.Next(-800, 800), P.Center.Y);
                        float   aimer = Main.rand.Next(-1000, 1000);
                        if ((counter % 600) > 540 && Main.expertMode)
                        {
                            Idglib.Shattershots(new Vector2(P.Center.X - 800, P.Center.Y), new Vector2(P.Center.X + 800, P.Center.Y), new Vector2(0, 0), mod.ProjectileType("CirnoBolt"), 25, (float)Main.rand.Next(60, 80) / 8, 0, 1, true, (float)(aimer / 9000), false, 200);
                            Idglib.Shattershots(new Vector2(P.Center.X + 800, P.Center.Y), new Vector2(P.Center.X - 800, P.Center.Y), new Vector2(0, 0), mod.ProjectileType("CirnoBolt"), 25, (float)Main.rand.Next(60, 80) / 8, 0, 1, true, (float)(aimer / 9000), false, 200);
                        }
                        Idglib.Shattershots(new Vector2(vis.X, P.Center.Y - 600f), new Vector2(vis.X, vis.Y + 600f), new Vector2(0, 0), mod.ProjectileType("CirnoIceShard"), 20, (float)Main.rand.Next(60, 80) / 10, 0, 1, true, (float)(aimer / 5000), false, 200);
                    }
                }
                if (card == 2)
                {
                    if (Main.expertMode)
                    {
                        if (mixup < 100)
                        {
                            mixup = 100;
                            for (int i = -400; i <= 401; i = i + 800)
                            {
                                List <Projectile> itz = Idglib.Shattershots(npc.Center - new Vector2(i * 3, 50), npc.Center, new Vector2(0, 50), mod.ProjectileType("SnowCloud"), 40, 2f, 0, 1, true, 0, false, 1000);
                                itz[0].velocity = itz[0].velocity + new Vector2(0, -4);
                            }
                        }


                        if (counter % 350 == 0)
                        {
                            Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 30, 1f, -0.5f);
                            for (int i = -200; i <= 201; i = i + 50)
                            {
                                Idglib.Shattershots(new Vector2(P.Center.X - 600, P.Center.Y + i), P.Center + new Vector2(0, i), new Vector2(0, 0), mod.ProjectileType("CirnoIceShard"), 30, (float)2, 0, 1, true, 0, false, 190);
                                Idglib.Shattershots(new Vector2(P.Center.X + 600, P.Center.Y + i), P.Center + new Vector2(0, i), new Vector2(0, 0), mod.ProjectileType("CirnoIceShard"), 30, (float)2, 0, 1, true, 0, false, 190);
                            }
                        }
                    }
                    if ((counter) % 120 == 0)
                    {
                        Idglib.Shattershots(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), P.position, new Vector2(P.width, P.height), ProjectileID.EnchantedBeam, 50, (float)13, 0, 1, true, 0, false, 120);
                    }
                    if ((counter - 30) % 120 == 0)
                    {
                        Idglib.Shattershots(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), P.position, new Vector2(P.width, P.height), mod.ProjectileType("CirnoIceShard"), 20, (float)7, 135, 8, true, 0, false, 160); Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 30, 1f, 0f);
                    }
                    if ((counter - 60) % 120 == 0)
                    {
                        Idglib.Shattershots(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), P.position, new Vector2(P.width, P.height), mod.ProjectileType("CirnoIceShard"), 20, (float)9, 85, 4, false, 0, false, 140); Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 30, 1f, 0.30f);
                    }
                }

                if (card == 3)
                {
                    if (counter % 8 == 0)
                    {
                        Idglib.Shattershots(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), P.position, new Vector2(P.width, P.height), 263, 35, (float)(counter / 8), 0, 1, true, (float)(counter - 140) / 70, true, 120);
                        Idglib.Shattershots(new Vector2(npc.Center.X + (npc.direction * 48), npc.Center.Y), P.position, new Vector2(P.width, P.height), 263, 35, (float)(counter / 8), 0, 1, true, -(float)(counter - 140) / 70, true, 120);
                    }
                    if (counter % 200 == 0)
                    {
                        aicounter   = 0;
                        aistate     = 10;
                        framevar    = 0;
                        stateaction = 1;
                        frameid     = 6;
                        attacktype  = 0;//(int)Main.rand.Next(0,2);
                    }
                }
            }
        }
Example #27
0
        public override void AI()
        {
            float speedmulti = 0.75f;

            if (GetType() == typeof(CopperWraith))
            {
                if (!Main.expertMode)
                {
                    speedmulti = 0.5f;
                }
                if (SGAWorld.NightmareHardcore > 0)
                {
                    speedmulti = 1f;
                }
            }

            if (GetType() == typeof(CobaltWraith))
            {
                speedmulti = 1.25f;
                if (!Main.expertMode)
                {
                    speedmulti = 1f;
                }
                if (SGAWorld.NightmareHardcore > 0)
                {
                    speedmulti = 1.4f;
                }
            }

            //npc.netUpdate = true;
            Player P = Main.player[npc.target];

            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(false);
                P = Main.player[npc.target];
                if (!P.active || P.dead)
                {
                    npc.active = false;
                    Main.npc[(int)npc.ai[1]].active = false;
                }
            }
            else
            {
                int expert = 0;
                if (Main.expertMode)
                {
                    expert = 1;
                }
                npc.ai[0] += 1;
                if (npc.type == mod.NPCType("CobaltWraith"))
                {
                    level = 1;
                }
                npc.defense = (int)(((NPC.CountNPCS(mod.NPCType("CopperArmorChainmail")) * 6) + (NPC.CountNPCS(mod.NPCType("CopperArmorGreaves"))) * 3 + (NPC.CountNPCS(mod.NPCType("CopperArmorHelmet")) * 4)) * ((expert + 1) * 0.4f));
                if (NPC.CountNPCS(mod.NPCType("CopperArmorChainmail")) + NPC.CountNPCS(mod.NPCType("CobaltArmorChainmail")) < 1)
                {
                    if (npc.ai[0] > 50)
                    {
                        npc.ai[0] = -500;
                    }
                }
                if (npc.life < npc.lifeMax * 0.5f)
                {
                    if (expert > 0)
                    {
                        if (npc.ai[0] > -1500 && npc.ai[1] == 0)
                        {
                            npc.ai[0] = -2000; npc.ai[1] = 1;
                        }
                        if (npc.ai[0] == -1850)
                        {
                            List <Projectile> itz = Idglib.Shattershots(npc.position, npc.position + new Vector2(0, 200), new Vector2(0, 0), ProjectileID.DD2BetsyArrow, 10, 5, 360, 20, true, 0, true, 150);
                            for (int f = 0; f < 20; f = f + 1)
                            {
                                itz[f].aiStyle  = 0;
                                itz[f].rotation = -((float)Math.Atan2((double)itz[f].velocity.Y, (double)itz[f].velocity.X));
                            }
                            SpawnMoreExpert();
                        }
                        if (npc.ai[0] == -1800)
                        {
                            npc.ai[0] = 0;
                        }
                    }
                }
                if ((npc.ai[0] == 1 || npc.ai[0] == -1) && npc.ai[1] < 1)
                {
                    float mul = (npc.ai[0] < 0 ? 0.10f : 0.45f);
                    if (NPC.CountNPCS(mod.NPCType("CopperArmorChainmail")) < 1)
                    {
                        int newguy = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 10, mod.NPCType(level > 0 ? "CobaltArmorChainmail" : "CopperArmorChainmail")); NPC newguy2 = Main.npc[newguy]; CopperArmorPiece newguy3 = newguy2.modNPC as CopperArmorPiece; newguy3.attachedID = npc.whoAmI; newguy2.lifeMax = (int)npc.lifeMax * 2; newguy2.life = (int)(npc.lifeMax * (2 * mul)); newguy2.knockBackResist = 0.85f; newguy2.netUpdate = true;
                    }
                    if (NPC.CountNPCS(mod.NPCType("CopperArmorSword")) < 1)
                    {
                        int newguy = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 10, mod.NPCType(level > 0 ? "CobaltArmorSword" : "CopperArmorSword")); NPC newguy2 = Main.npc[newguy]; CopperArmorPiece newguy3 = newguy2.modNPC as CopperArmorPiece; newguy3.attachedID = npc.whoAmI; newguy2.ai[1] = -32f; newguy2.ai[2] = -16f; newguy2.lifeMax = (int)(npc.lifeMax * 1f); newguy2.life = (int)(npc.lifeMax * (1f)); newguy2.knockBackResist = 0.75f; newguy2.netUpdate = true;
                    }
                    if (NPC.CountNPCS(mod.NPCType("CopperArmorHelmet")) < 1)
                    {
                        int newguy = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 10, mod.NPCType(level > 0 ? "CobaltArmorHelmet" : "CopperArmorHelmet")); NPC newguy2 = Main.npc[newguy]; CopperArmorPiece newguy3 = newguy2.modNPC as CopperArmorPiece; newguy3.attachedID = npc.whoAmI; newguy2.ai[2] = -12f; newguy2.lifeMax = (int)(npc.lifeMax * 1.5f); newguy2.life = (int)(npc.lifeMax * (1.5f * mul)); newguy2.knockBackResist = 0.8f; newguy2.netUpdate = true;
                    }
                    if (NPC.CountNPCS(mod.NPCType("CopperArmorGreaves")) < 1)
                    {
                        int newguy = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 10, mod.NPCType(level > 0 ? "CobaltArmorGreaves" : "CopperArmorGreaves")); NPC newguy2 = Main.npc[newguy]; CopperArmorPiece newguy3 = newguy2.modNPC as CopperArmorPiece; newguy3.attachedID = npc.whoAmI; newguy2.ai[2] = 12f; newguy2.lifeMax = (int)(npc.lifeMax * 1.5f); newguy2.life = (int)(npc.lifeMax * (1.5f * mul)); newguy2.knockBackResist = 0.8f; newguy2.netUpdate = true;
                    }
                    if (NPC.CountNPCS(mod.NPCType("CopperArmorBow")) < 1)
                    {
                        int newguy = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 10, mod.NPCType(level > 0 ? "CobaltArmorSword" : "CopperArmorBow")); NPC newguy2 = Main.npc[newguy]; CopperArmorPiece newguy3 = newguy2.modNPC as CopperArmorPiece; newguy3.attachedID = npc.whoAmI; newguy2.ai[1] = 32f; newguy2.ai[2] = -16f; newguy2.lifeMax = (int)(npc.lifeMax * (1f)); newguy2.life = (int)(npc.lifeMax * (1f)); newguy2.knockBackResist = 0.75f; newguy2.netUpdate = true;
                    }
                }
                if (npc.ai[0] > 1)
                {
                    if (npc.ai[0] % 600 < 250)
                    {
                        Vector2 itt = ((P.Center + OffsetPoints) - npc.position); itt.Normalize();
                        npc.velocity = npc.velocity + (itt * (speed * speedmulti));
                    }
                    npc.velocity = npc.velocity * 0.98f;
                }
                if (npc.ai[0] < 0 && npc.ai[0] > -2000)
                {
                    if (npc.ai[0] % 110 < -95)
                    {
                        npc.velocity = new Vector2(Main.rand.Next(-20, 20), 0);
                        if (npc.ai[0] % 10 == 0)
                        {
                            Idglib.Shattershots(npc.position, P.position, new Vector2(P.width, P.height), 100, 10, 8, 0, 1, true, 0, true, 300);
                        }
                    }
                    else
                    {
                        Vector2 itt    = ((P.Center + OffsetPoints + new Vector2(0, -250)) - npc.position); itt.Normalize();
                        float   speedz = (float)level + 0.45f;
                        npc.velocity = npc.velocity + ((itt * speedz) * speedmulti);
                    }
                    float fric = 0.96f + ((float)level * 0.01f);
                    npc.velocity = npc.velocity * fric;
                }
            }
        }
Example #28
0
        public override void AI()
        {
            npc.timeLeft = 30;
            if (oldtype < 1)
            {
                oldtype = npc.type;
            }
            npc.netUpdate = true;
            Player P = Main.player[npc.target];

            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active || NPC.CountNPCS(NPCID.Golem) < 1)
            {
                npc.TargetClosest(false);
                P = Main.player[npc.target];
                if (NPC.CountNPCS(NPCID.Golem) < 1)
                {
                    npc.active = false;
                }
            }
            else
            {
                npc.ai[0] += 1;
                int npctype = NPCID.Golem;
                if (NPC.CountNPCS(npctype) > 0)
                {
                    NPC myowner = Main.npc[NPC.FindFirstNPC(NPCID.Golem)];
                    npc.position = myowner.position;
                    if (anticheese % 500 < 400)
                    {
                        if (!Collision.CanHitLine(new Vector2(myowner.Center.X, myowner.Center.Y), 1, 1, new Vector2(P.Center.X, P.Center.Y), 1, 1))
                        {
                            anticheese += 1;
                        }
                    }
                    else
                    {
                    }
                    if (NPC.CountNPCS(NPCID.GolemHeadFree) > 0)
                    {
                        NPC myhead = Main.npc[NPC.FindFirstNPC(NPCID.GolemHeadFree)];
                        if (phase == 0)
                        {
                            phase                 = 1;
                            myhead.lifeMax        = myowner.lifeMax;
                            myhead.life           = myowner.lifeMax;
                            myhead.dontTakeDamage = false;
                        }
                    }
                    if (NPC.CountNPCS(NPCID.GolemHeadFree) < 1 && phase == 1)
                    {
                        phase = 2;
                    }
                    if (phase == 0)
                    {
                        minlife = myowner.life;
                    }
                    if (phase == 1)
                    {
                        myowner.life = minlife;
                        if (Main.expertMode)
                        {
                            minlife += 1;
                        }
                    }

                    Vector2 angledif = P.Center - myowner.Center; angledif.Normalize();
                    float   angle    = npc.velocity.ToRotation().AngleLerp(angledif.ToRotation(), (0.50f - ((float)myowner.life / (float)myowner.lifeMax) * 0.25f) * 0.25f);
                    if (npc.ai[0] % 900 > 600 && npc.ai[0] % 900 < 800)
                    {
                        for (int a = 0; a < 2000; a += Main.rand.Next(36, 64))
                        {
                            Vector2 there  = npc.velocity * a;
                            int     num622 = Dust.NewDust(new Vector2(myowner.Center.X, myowner.Center.Y) + there, 0, 0, 6, 0f, 0f, 100, default(Color), 1f);
                        }
                    }

                    if (npc.ai[0] % 900 > 800)
                    {
                        if (npc.ai[0] % 20 == 0)
                        {
                            Idglib.Shattershots(myowner.Center, myowner.Center + npc.velocity, Vector2.Zero, ProjectileID.CultistBossFireBall, 40, 12, 90, 1, true, 0, false, 220);
                        }
                        if (npc.ai[0] % 3 == 0)
                        {
                            for (int i = 0; i < 1000; i += 400)
                            {
                                List <Projectile> itz = Idglib.Shattershots(myowner.Center + (npc.velocity * i), myowner.Center + (npc.velocity * i) + npc.velocity, Vector2.Zero, ProjectileID.FlamesTrap, 40, 12, 90, 1, true, 0, false, 220);
                                itz[0].friendly = false;
                                itz[0].hostile  = true;
                            }
                        }
                    }
                    else
                    {
                        npc.velocity = angle.ToRotationVector2();
                    }

                    if (phase == 1 && npc.ai[0] % 300 == 0)
                    {
                        List <Projectile> itz = Idglib.Shattershots(myowner.Center, P.position, new Vector2(P.width, P.height), ProjectileID.CultistBossFireBall, 40, 8, 140, 2, true, 0, false, 220);
                        //itz[0].aiStyle=5;
                    }

                    if (phase > 0 && npc.ai[0] % 900 > 700)
                    {
                        bool cond = npc.ai[0] % 900 == 899;
                        for (int a = 0; a < 20 + (cond ? 60 : 0); a++)
                        {
                            Vector2 randomcircle = new Vector2(Main.rand.Next(-8000, 8000), Main.rand.Next(-8000, 8000)); randomcircle.Normalize();
                            Vector2 vecr         = randomcircle * 240;
                            vecr *= (1f - (900f / (npc.ai[0] % 900)));

                            randomcircle *= (cond ? Main.rand.NextFloat(3f, 10f) : 1f);
                            int num622 = Dust.NewDust(new Vector2(myowner.Center.X, myowner.Center.Y) + vecr, 0, 0, 6, randomcircle.X, randomcircle.Y, 100, default(Color), 0.5f + (((npc.ai[0] - 400f) % 900) / 300f));
                            Main.dust[num622].velocity  = randomcircle;
                            Main.dust[num622].noGravity = true;
                        }
                        if (cond)
                        {
                            Main.PlaySound(SoundID.Item, (int)myowner.Center.X, (int)myowner.Center.Y, 74, 1f, 0f);
                        }
                    }


                    if (phase > 0 && npc.ai[0] % 900 == 0)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            List <Projectile> itz = Idglib.Shattershots(myowner.Center, myowner.Center, new Vector2(0, 0), mod.ProjectileType("Ringproj"), 60, 14, 0, 1, true, Main.rand.Next(-360, 360), false, 420);
                            itz[0].timeLeft    = 200;
                            itz[0].tileCollide = true;
                            //itz[0].aiStyle=5;
                        }
                    }
                    if ((phase > 0 && (npc.ai[0] * (phase == 2 ? 1.5f : 1f)) % 600 > (phase == 2 ? 450 : 500) && myowner.velocity.Y < 0) || anticheese % 500 > 399)
                    {
                        if (myowner.velocity.Y < 0)
                        {
                            myowner.noTileCollide = true;
                            myowner.velocity      = myowner.velocity + (new Vector2(P.Center.X > myowner.Center.X ? 1 : -1, -0.25f));
                            if (anticheese % 500 > 399)
                            {
                                anticheese += 1;
                            }
                            //itz[0].aiStyle=5;
                        }
                    }


                    if (phase == 2)
                    {
                        if (System.Math.Abs(myowner.velocity.Y) < 1)
                        {
                            if ((npc.ai[0]) % 600 > 400 && (npc.ai[0]) % 10 == 0)
                            {
                                List <Projectile> itz = Idglib.Shattershots(myowner.Center, P.position + new Vector2((float)Main.rand.Next(-150, 150), -700f), new Vector2(P.width, P.height), ProjectileID.DD2BetsyFireball, 70, 30, 0, 1, true, 0, false, 220);
                                itz[0].timeLeft    = 600;
                                itz[0].tileCollide = false;
                                SGAprojectile modeproj = itz[0].GetGlobalProjectile <SGAprojectile>();
                                modeproj.raindown  = true;
                                modeproj.splithere = P.Center + new Vector2(0, 200);
                            }
                        }
                    }
                    if (myowner.velocity.Y > 0 && (myowner.Center.Y > P.Center.Y - 100))
                    {
                        myowner.noTileCollide = false;
                    }
                    else
                    {
                        myowner.noTileCollide = true;
                    }

                    if (myowner.velocity.Y < -1)
                    {
                        myowner.noTileCollide = true;
                    }
                }
            }
        }
Example #29
0
        public override void AI()
        {
            CopperArmorPiece myself = npc.modNPC as CopperArmorPiece;
            int npctype             = mod.NPCType(myself.attachedType);
            NPC myowner             = Main.npc[myself.attachedID];

            if (myowner.active == false)
            {
                myself.ArmorMalfunction();
            }
            else
            {
                Player P = Main.player[npc.target];
                if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
                {
                    npc.TargetClosest(false);
                    P = Main.player[npc.target];
                    if (!P.active || P.dead)
                    {
                        npc.active = false;
                        Main.npc[(int)npc.ai[1]].active = false;
                    }
                }
                else
                {
                    npc.ai[0] += 1;
                    Vector2 itt = (myowner.Center - npc.Center + new Vector2(npc.ai[1] * npc.spriteDirection, npc.ai[2]));
                    if (npc.ai[0] % 1500 > 1250)
                    {
                        itt = (P.position - npc.position + new Vector2(3f * npc.ai[1] * npc.spriteDirection, npc.ai[2] * 2f));
                    }
                    float locspeed = 0.25f;
                    if (npc.ai[0] % 900 > 550)
                    {
                        Vector2 cas      = new Vector2(npc.position.X - P.position.X, npc.position.Y - P.position.Y);
                        double  dist     = cas.Length();
                        float   rotation = (float)Math.Atan2(npc.position.Y - (P.position.Y - (new Vector2(0, (float)(dist * 0.05f))).Y + (P.height * 0.5f)), npc.position.X - (P.position.X + (P.width * 0.5f)));
                        npc.rotation = rotation;//npc.rotation+((rotation-npc.rotation)*0.1f);
                        npc.velocity = npc.velocity * 0.86f;
                        if (npc.ai[0] % 20 == 0 && npc.ai[0] % 900 > 650)
                        {
                            List <Projectile> one = Idglib.Shattershots(npc.Center, npc.Center + new Vector2(-15 * npc.spriteDirection, 0), new Vector2(0, 0), SGAWorld.NightmareHardcore > 0 ? mod.ProjectileType("UnmanedArrow2") : ProjectileID.WoodenArrowHostile, 20, 20, 0, 1, true, (Main.rand.Next(-100, 100) * 0.000f) - npc.rotation, true, 300);
                            one[0].hostile    = true;
                            one[0].friendly   = false;
                            one[0].localAI[0] = P.whoAmI;
                            one[0].netUpdate  = true;
                        }
                        npc.spriteDirection = 1;
                    }
                    else
                    {
                        if (Math.Abs(npc.velocity.X) > 2)
                        {
                            npc.spriteDirection = npc.velocity.X > 0 ? -1 : 1;
                        }
                        npc.rotation = (float)npc.velocity.X * 0.09f;
                        locspeed     = 0.5f;
                    }
                    npc.velocity = npc.velocity * 0.96f;
                    itt.Normalize();
                    npc.velocity = npc.velocity + (itt * locspeed);
                    npc.timeLeft = 999;
                }
            }
        }
Example #30
0
        public void DoPhase(int phasetype)
        {
            if (phasetype > 0)
            {
                if (phase == 1)
                {
                    if (npc.life < npc.lifeMax * (Main.expertMode ? 0.5f : 0.33f))
                    {
                        npc.ai[0] = 10000;
                        phase     = 2;
                        return;
                    }
                }
                if (phase == 0)
                {
                    npc.ai[0] = 10000;
                    phase     = 1;
                    return;
                }


                //Phase 2-Charging
                if (npc.ai[0] > 1999 && npc.ai[0] < 3000)
                {
                    if (npc.ai[0] > 2998)
                    {
                        npc.ai[0] = 0;
                        return;
                    }
                    if (npc.ai[0] % 210 < 90 && npc.ai[0] % 210 > 25)
                    {
                        npc.rotation = npc.rotation.AngleLerp((P.Center - npc.Center).ToRotation(), 0.15f);
                        if (npc.ai[0] % 20 == 0 && Main.expertMode)
                        {
                            Idglib.Shattershots(npc.Center + npc.rotation.ToRotationVector2() * 32, npc.Center + npc.rotation.ToRotationVector2() * 200, new Vector2(0, 0), ProjectileID.WebSpit, 15, 20, 35, 1, true, 0, false, 1600);
                            Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 102, 0.25f, -0.25f);
                        }
                    }
                    if (npc.ai[0] % 210 > 100 && npc.ai[0] % 210 < 200)
                    {
                        charge = true;
                        if (npc.ai[0] % 210 == 105)
                        {
                            Main.PlaySound(SoundID.Roar, (int)npc.Center.X, (int)npc.Center.Y, 0, 1f, 0.25f);
                        }
                        npc.velocity += npc.rotation.ToRotationVector2() * 2f;

                        if ((npc.ai[0] % (Main.expertMode ? 15 : 20)) == 0 && phase > 1)
                        {
                            Idglib.Shattershots(npc.Center, npc.Center + (npc.rotation + MathHelper.ToRadians(90)).ToRotationVector2() * 64, new Vector2(0, 0), mod.ProjectileType("SpiderVenom"), 10, 7, 35, 1, true, 0, true, 1600);
                            Idglib.Shattershots(npc.Center, npc.Center + (npc.rotation + MathHelper.ToRadians(-90)).ToRotationVector2() * 64, new Vector2(0, 0), mod.ProjectileType("SpiderVenom"), 10, 7, 35, 1, true, 0, true, 1600);
                            Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 102, 0.25f, -0.25f);
                        }

                        if (npc.velocity.Length() > 96f)
                        {
                            npc.velocity.Normalize();
                            npc.velocity *= 96f;
                        }
                    }
                    npc.localAI[0] += npc.velocity.Length() / 3f;
                    npc.velocity   /= 1.15f;
                }
            }

            //Spinning Trap Webs
            if (npc.ai[0] > 2999 && npc.ai[0] < 4000)
            {
                if (npc.ai[0] == 3005)
                {
                    Main.PlaySound(3, (int)npc.Center.X, (int)npc.Center.Y, 56, 0.25f, -0.25f);
                }

                if (npc.ai[0] > 3100 && npc.ai[0] < 3300)
                {
                    float angle1; float angle2;
                    GetAngleDifferenceBlushiMagic(new Vector2(npc.localAI[1], npc.localAI[2]), out angle1, out angle2);
                    float rotSpeed = angle2 > angle1 ? 0.05f : -0.05f;
                    rotSpeed *= 1f + ((float)(angle2 - angle1) * 0.2f);

                    npc.rotation += rotSpeed;
                    if (npc.ai[0] % 10 == 0)
                    {
                        int type = mod.ProjectileType("TrapWeb");
                        Idglib.Shattershots(npc.Center + npc.rotation.ToRotationVector2() * 32, npc.Center + npc.rotation.ToRotationVector2() * 200, new Vector2(0, 0), type, 15, 7, 35, 1, true, 0, true, 1600);
                        Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 102, 0.25f, -0.25f);
                    }

                    if (npc.ai[0] % 150 == 31)
                    {
                        npc.localAI[1] = P.Center.X;
                        npc.localAI[2] = P.Center.Y;
                    }
                }

                if (npc.ai[0] > 3350)
                {
                    npc.ai[0]     = Main.rand.Next(2400, 2700);
                    npc.netUpdate = true;
                }

                npc.velocity *= 0.96f;
            }


            //Wounded
            if (npc.ai[0] > 9999)
            {
                npc.velocity /= 1.25f;
                if (npc.ai[0] == 10001)
                {
                    Main.PlaySound(3, (int)npc.Center.X, (int)npc.Center.Y, 51, 1f, 0.25f);
                }
                npc.rotation += Main.rand.NextFloat(1f, -1f) * 0.08f;


                if (npc.ai[0] > 10100)
                {
                    if (phase == 1)
                    {
                        npc.ai[0] = 2000;
                    }
                }
                if (npc.ai[0] > 10100)
                {
                    if (phase == 2)
                    {
                        npc.ai[0] = 3000;
                    }
                }
            }
        }