Ejemplo n.º 1
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (projectile.ai[0] == 0)
            {
                projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.DirectionTo(pos) * projectile.Distance(pos) / 10, 0.2f);
                if ((projectile.velocity.X + projectile.velocity.Y) / 2 < 2f)
                {
                    foreach (Projectile proj in Main.projectile)
                    {
                        if (proj.type == ProjectileID.Bullet || proj.type == ProjectileID.BulletHighVelocity)
                        {
                            if (proj.Distance(projectile.Center) < 22)
                            {
                                projectile.velocity = proj.velocity.SafeNormalize(Vector2.Zero) * 6f;

                                if (UsefulMethods.ClosestNPC(ref target, 1000, projectile.Center, true))
                                {
                                    proj.velocity = proj.DirectionTo(target.Center) * 15f;
                                }
                                else
                                {
                                    proj.velocity = proj.DirectionFrom(projectile.Center) * 15f;
                                }
                                Main.PlaySound(SoundID.NPCHit4, projectile.Center);
                                Main.PlaySound(SoundID.NPCHit5, projectile.Center);
                            }
                        }
                    }
                }
            }
            else
            {
                float vel = (projectile.velocity.X + projectile.velocity.Y) / 2;
                projectile.ai[1]++;
                projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.DirectionTo(player.Center) * projectile.ai[1] / 2, 0.1f);
                if (projectile.Distance(player.Center) < vel * 3)
                {
                    projectile.active = false;
                }
            }

            projectile.rotation += MathHelper.ToRadians(19f);

            projectile.spriteDirection = 1;
        }
Ejemplo n.º 2
0
        public override void AI()
        {
            Player player         = Main.player[projectile.owner];
            bool   isTargetingNPC = false;

            float ang = MathHelper.ToRadians(360 / (float)Math.Floor(Main.player[projectile.owner].ownedProjectileCounts[mod.ProjectileType("Shadowsoul")] + 0.5f) * projectile.minionPos);

            if (Main.player[projectile.owner].ownedProjectileCounts[mod.ProjectileType("Shadowsoul")] <= 1)
            {
                ang = 0f;
            }

            Vector2 flyTo = player.Center + new Vector2(0, 100).RotatedBy(ang + MathHelper.ToRadians(DayriseWorld.globalTimer * 2f));

            if (UsefulMethods.ClosestNPC(ref target, 1300, player.Center, true))
            {
                isTargetingNPC = true;
            }

            timer++;

            if (isTargetingNPC)
            {
                flyTo = target.Center + new Vector2(0, -100 + ((float)Math.Sin(DayriseWorld.globalTimer * 0.1f) * 200)).RotatedBy(ang + MathHelper.ToRadians(DayriseWorld.globalTimer * 2f));

                if (DayriseWorld.globalTimer * 0.1f % 6f <= 0.05f)
                {
                    projectile.ai[1] = 5;
                }
            }

            projectile.rotation  = 0;
            projectile.rotation += projectile.velocity.X * 0.01f;
            if (projectile.rotation > 0.5f)
            {
                projectile.rotation = 0.5f;
            }
            if (projectile.rotation < -0.5f)
            {
                projectile.rotation = -0.5f;
            }

            projectile.velocity = projectile.DirectionTo(flyTo) * projectile.Distance(flyTo) / 22;
        }
Ejemplo n.º 3
0
        public override void AI()
        {
            Player player         = Main.player[projectile.owner];
            bool   isTargetingNPC = false;

            if (UsefulMethods.ClosestNPC(ref target, 500, player.Center))
            {
                isTargetingNPC = true;
            }

            timer++;

            if (timer % 60 == 0)
            {
                if (isTargetingNPC)
                {
                    if (target != null && target.active)
                    {
                        for (int i = 0; i < Main.rand.Next(4, 7); i++)
                        {
                            Projectile.NewProjectile(projectile.Center, (projectile.DirectionTo(target.Center).RotatedBy(MathHelper.ToRadians(Main.rand.Next(-12, 12)))) * Main.rand.Next(5, 10) + new Vector2(0, -1), mod.ProjectileType("BloodProj3"), 9, 6f, player.whoAmI);
                        }
                    }
                }
            }

            projectile.rotation  = 0;
            projectile.rotation += projectile.velocity.X * 0.01f;
            if (projectile.rotation > 0.5f)
            {
                projectile.rotation = 0.5f;
            }
            if (projectile.rotation < -0.5f)
            {
                projectile.rotation = -0.5f;
            }

            Vector2 flyTo;

            flyTo = Main.player[projectile.owner].Center + new Vector2(-player.direction * (23 * (projectile.ai[0] + 1)), -60 + (3 * projectile.ai[0]));

            projectile.velocity = projectile.DirectionTo(flyTo) * projectile.Distance(flyTo) / 25 + new Vector2((float)Math.Cos((projectile.ai[0] * 0.2f) + timer * 0.04) * 2f, (float)Math.Cos((projectile.ai[0] * 0.2f) + timer * 0.03) * 3f);
        }
Ejemplo n.º 4
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (!start)
            {
                targetPos = projectile.Center + new Vector2(0, 100);
                flyTo     = player.Center;
                start     = true;
            }

            bool isTargetingNPC = false;

            projectile.ai[0] = projectile.minionPos % 3;

            float ang = MathHelper.ToRadians(360 / (float)Math.Floor(Main.player[projectile.owner].ownedProjectileCounts[mod.ProjectileType("GunMinion")] + 0.5f) * projectile.minionPos);

            if (Main.player[projectile.owner].ownedProjectileCounts[mod.ProjectileType("GunMinion")] <= 1)
            {
                ang = 0f;
            }

            if (UsefulMethods.ClosestNPC(ref target, 600, player.Center))
            {
                isTargetingNPC = true;
            }

            Vector2 gung = new Vector2(0, 75).RotatedBy(ang + (DayriseWorld.globalTimer / 75));

            gung.Y *= 0.7f;

            projectile.ai[1]++;

            if (isTargetingNPC)
            {
                float cos1 = (DayriseWorld.globalTimer * 0.04f) + (projectile.minionPos * 0.1f);

                int timeCap = 10;
                if (projectile.ai[0] == 0)
                {
                    flyTo = Vector2.Lerp(player.Center, target.Center, 0.25f) + new Vector2(0, -130 + (float)Math.Cos(cos1) * 32);
                }
                if (projectile.ai[0] == 1)
                {
                    timeCap = 65;
                    flyTo   = target.Center + (target.DirectionTo(player.Center) * (126 + (target.width + target.height / 2)));
                }
                if (projectile.ai[0] == 2)
                {
                    timeCap = 120;
                    flyTo   = Vector2.Lerp(player.Center, target.Center, 0.1f) + new Vector2(0, -60 + (float)Math.Cos(cos1) * 32);
                }

                if (projectile.ai[1] >= timeCap)
                {
                    Vector2 vel = projectile.DirectionTo(targetPos);

                    projectile.ai[1] = Main.rand.Next(-20, 1);

                    if (projectile.ai[0] == 2)
                    {
                        Main.PlaySound(SoundID.Item40, projectile.Center);
                        Projectile.NewProjectile(projectile.Center, (vel * Main.rand.Next(17, 21)), mod.ProjectileType("Soulbullet"), 102, 2f, player.whoAmI);
                    }
                    else if (projectile.ai[0] == 1)
                    {
                        Main.PlaySound(SoundID.Item36, projectile.Center);
                        for (int i = 0; i < 4; i++)
                        {
                            Projectile.NewProjectile(projectile.Center, (vel * Main.rand.Next(16, 20)).RotatedBy(MathHelper.ToRadians(Main.rand.Next(-12, 13))), mod.ProjectileType("Soulbullet"), 30, 2f, player.whoAmI, ai1: 1);
                        }
                    }
                    else
                    {
                        Main.PlaySound(SoundID.Item11, projectile.Center);
                        Projectile.NewProjectile(projectile.Center, (vel * Main.rand.Next(13, 16)).RotatedBy(MathHelper.ToRadians(Main.rand.Next(-4, 5))), mod.ProjectileType("Soulbullet"), 19, 2f, player.whoAmI);

                        projectile.ai[1] = Main.rand.Next(0);
                    }

                    projectile.velocity += -vel * 6f;
                }

                flyTo += gung;

                targetPos = Vector2.Lerp(targetPos, target.Center, 0.05f);

                //if (!target.active)
                {
                }
            }
            else
            {
                flyTo     = player.Center + new Vector2(0, -65) + gung;
                targetPos = Vector2.Lerp(targetPos, player.Center + new Vector2(player.direction * 150, 0), 0.15f);

                projectile.ai[1] = 0;
            }

            projectile.rotation = projectile.AngleTo(targetPos);

            projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.DirectionTo(flyTo) * projectile.Distance(flyTo) / 20, 0.2f);
        }