Exemple #1
0
        public override void AI()
        {
            int num1 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 15, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f);

            Main.dust[num1].noGravity = true;
            Main.dust[num1].velocity *= 0.9f;

            if (projectile.timeLeft <= 300f || (ProjectileUtils.CountProjectiles(projectile.type) > 1 && ProjectileUtils.HasLeastTimeleft(projectile.whoAmI)))
            {
                projectile.alpha += 5;
                if (projectile.alpha > 255)
                {
                    projectile.alpha = 255;
                    projectile.Kill();
                }
            }

            projectile.localAI[1]--;
            if (projectile.owner == Main.myPlayer)
            {
                float max = 400f;
                for (int i = 0; i < Main.npc.Length; i++)
                {
                    NPC nPC = Main.npc[i];
                    if (nPC.active && !nPC.friendly && nPC.damage > 0 && !nPC.dontTakeDamage && Vector2.Distance(projectile.Center, nPC.Center) <= max)
                    {
                        float Speed    = 9f;
                        float rotation = (float)Math.Atan2(projectile.Center.Y - nPC.Center.Y, projectile.Center.X - nPC.Center.X);
                        if (projectile.localAI[1] <= 0)
                        {
                            Vector2 speed = new Vector2((float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1));
                            //Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 12);
                            Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, speed.X, speed.Y, mod.ProjectileType("LightningBlast"), projectile.damage, projectile.knockBack, projectile.owner);
                            projectile.localAI[1] = Main.rand.Next(16, 60);
                        }
                    }
                }
            }
        }
Exemple #2
0
        public override void AI()
        {
            projectile.velocity.X = 0f;
            projectile.velocity.Y = 0f;
            if (Main.rand.Next(3) == 0)
            {
                int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.PinkFlame);
                Main.dust[dust].noGravity = true;
                Main.dust[dust].scale     = 1f;
            }
            if (!hasOrbital)
            {
                int swirlCount = 12;
                for (int l = 0; l < swirlCount; l++)
                {
                    int distance = 360 / swirlCount;
                    int orbital  = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, mod.ProjectileType("BlackholeOrbit"), projectile.damage, projectile.knockBack, 0, l * distance, projectile.whoAmI);
                }
                hasOrbital = true;
            }
            if (ProjectileUtils.CountProjectiles(projectile.type) > 3)
            {
                if (ProjectileUtils.HasLeastTimeleft(projectile.whoAmI))
                {
                    projectile.alpha += 10;
                    if (projectile.alpha >= 255)
                    {
                        projectile.Kill();
                    }
                }
            }
            // grav
            int   maxDist     = 400;
            float gravStength = 0.3f;

            for (int i = 0; i < Main.npc.Length; i++)
            {
                NPC  npc    = Main.npc[i];
                bool immune = false;
                foreach (int k in ElementsAwoken.instakillImmune)
                {
                    if (npc.type == k)
                    {
                        immune = true;
                    }
                }
                if (!immune && npc.active && npc.damage > 0 && !npc.boss && npc.lifeMax < 10000 && Vector2.Distance(npc.Center, projectile.Center) < maxDist)
                {
                    Vector2 toTarget = new Vector2(projectile.Center.X - npc.Center.X, projectile.Center.Y - npc.Center.Y);
                    toTarget.Normalize();
                    npc.velocity.X += toTarget.X * gravStength;
                    npc.velocity.Y += toTarget.Y * gravStength * 5;
                }
            }
            for (int i = 0; i < Main.item.Length; i++)
            {
                Item item = Main.item[i];
                if (item.active && Vector2.Distance(item.Center, projectile.Center) < maxDist)
                {
                    Vector2 toTarget = new Vector2(projectile.Center.X - item.Center.X, projectile.Center.Y - item.Center.Y);
                    toTarget.Normalize();
                    item.velocity += toTarget * gravStength;
                }
            }
        }