예제 #1
0
 public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
 {
     if (OrchidModAlchemistNPC.AttractiteCanHome(target) || !this.hasTarget)
     {
         projectile.Kill();
     }
 }
예제 #2
0
        public override void AI()
        {
            if (!this.initialized)
            {
                projectile.ai[1]     = Main.rand.Next(2) == 0 ? -1 : 1;
                projectile.timeLeft -= Main.rand.Next(15);
                projectile.netUpdate = true;
                this.initialized     = true;
            }

            if (projectile.timeLeft <= 550)
            {
                if (projectile.timeLeft == 550)
                {
                    projectile.velocity *= (float)((4 + Main.rand.Next(3)) / 10f);
                    projectile.friendly  = true;
                    projectile.netUpdate = true;
                }
                else
                {
                    Vector2 move     = Vector2.Zero;
                    float   distance = 2000f;
                    bool    target   = false;
                    for (int k = 0; k < 200; k++)
                    {
                        if (Main.npc[k].active && !Main.npc[k].dontTakeDamage && !Main.npc[k].friendly && Main.npc[k].lifeMax > 5 &&
                            OrchidModAlchemistNPC.AttractiteCanHome(Main.npc[k]))
                        {
                            Vector2 newMove    = Main.npc[k].Center - projectile.Center;
                            float   distanceTo = (float)Math.Sqrt(newMove.X * newMove.X + newMove.Y * newMove.Y);
                            if (distanceTo < distance)
                            {
                                move     = newMove;
                                distance = distanceTo;
                                target   = true;
                            }
                        }
                    }

                    if (target)
                    {
                        move.Normalize();
                        float vel = (1f + (distance * 0.03f));
                        vel   = vel > 10f ? 10f : vel;
                        move *= vel;
                        projectile.velocity = move;
                        projectile.timeLeft++;

                        if (Main.rand.Next(4) == 0)
                        {
                            int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 29);
                            Main.dust[dust].noGravity = true;
                            Main.dust[dust].noLight   = true;
                            Main.dust[dust].scale    *= 1.5f;
                        }
                    }
                    else
                    {
                        int angle = (int)(5 * projectile.ai[1]);
                        move = projectile.velocity.RotatedBy(MathHelper.ToRadians(angle));
                        move.Normalize();
                        move *= 3f;
                        projectile.velocity = move;
                    }
                }
            }
        }
예제 #3
0
        public override void AI()
        {
            if (!this.initialized)
            {
                this.orbitPoint  = projectile.Center;
                this.initialized = true;
            }

            projectile.ai[1]     = projectile.ai[1] + 1f + projectile.ai[0] >= 360f ? 0f : projectile.ai[1] + 1 + projectile.ai[0];
            projectile.rotation += 0.1f + (projectile.ai[0] / 30f);

            if (Main.rand.Next(30) == 0)
            {
                int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 21);
                Main.dust[dust].noGravity = true;
                Main.dust[dust].noLight   = true;
            }

            if (projectile.timeLeft <= 880)
            {
                if (projectile.timeLeft == 880)
                {
                    projectile.friendly  = true;
                    projectile.netUpdate = true;
                }
                else
                {
                    float  distance = 2000f;
                    Player player   = Main.player[projectile.owner];
                    if (player.HasBuff(BuffType <Alchemist.Buffs.StellarTalcBuff>()))
                    {
                        orbitPoint = player.Center;
                    }
                    else
                    {
                        for (int k = 0; k < 200; k++)
                        {
                            if (Main.npc[k].active && !Main.npc[k].dontTakeDamage && !Main.npc[k].friendly && Main.npc[k].lifeMax > 5 &&
                                OrchidModAlchemistNPC.AttractiteCanHome(Main.npc[k]))
                            {
                                Vector2 newMove    = Main.npc[k].Center - projectile.Center;
                                float   distanceTo = (float)Math.Sqrt(newMove.X * newMove.X + newMove.Y * newMove.Y);
                                if (distanceTo < distance)
                                {
                                    distance   = distanceTo;
                                    orbitPoint = Main.npc[k].Center;
                                }
                            }
                        }
                    }

                    Vector2 move = orbitPoint - projectile.Center + new Vector2(0f, 100f).RotatedBy(MathHelper.ToRadians(projectile.ai[1]));
                    distance = (float)Math.Sqrt(move.X * move.X + move.Y * move.Y);
                    move.Normalize();
                    float vel = (1f + (distance * 0.05f));
                    vel   = vel > 10f ? 10f : vel;
                    move *= vel;
                    projectile.velocity = move;
                }
            }
        }
예제 #4
0
        // public override Color? GetAlpha(Color lightColor) {
        // return Color.White;
        // }

        public override void AI()
        {
            projectile.velocity.Y += projectile.velocity.Y < 3f ? 0.1f : 0f;

            if (!this.initialized)
            {
                projectile.ai[1]     = Main.rand.Next(2) == 0 ? -1 : 1;
                projectile.timeLeft -= Main.rand.Next(15);
                projectile.netUpdate = true;
                this.initialized     = true;
            }

            if (projectile.timeLeft <= 550)
            {
                if (projectile.timeLeft == 550)
                {
                    projectile.velocity *= (float)((4 + Main.rand.Next(3)) / 10f);
                    projectile.friendly  = true;
                    projectile.netUpdate = true;
                }
                else
                {
                    Vector2 move     = Vector2.Zero;
                    float   distance = 2000f;
                    int     flag     = -1;
                    for (int k = 0; k < 200; k++)
                    {
                        if (Main.npc[k].active && !Main.npc[k].dontTakeDamage && !Main.npc[k].friendly && Main.npc[k].lifeMax > 5 &&
                            OrchidModAlchemistNPC.AttractiteCanHome(Main.npc[k]))
                        {
                            Vector2 newMove    = Main.npc[k].Center - projectile.Center;
                            float   distanceTo = (float)Math.Sqrt(newMove.X * newMove.X + newMove.Y * newMove.Y);
                            if (distanceTo < distance)
                            {
                                move     = newMove;
                                distance = distanceTo;
                                flag     = k;
                            }
                        }
                    }

                    if (flag > -1)
                    {
                        if (Main.npc[flag].Center.X > projectile.Center.X)
                        {
                            projectile.velocity.X += projectile.velocity.X < 5f ? 0.75f : 0f;
                        }
                        else
                        {
                            projectile.velocity.X -= projectile.velocity.X > -5f ? 0.75f : 0f;
                        }

                        projectile.timeLeft++;

                        if (Main.rand.Next(4) == 0)
                        {
                            int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 44);
                            Main.dust[dust].noGravity = true;
                            Main.dust[dust].noLight   = true;
                            Main.dust[dust].scale    *= 1.5f;
                        }
                    }
                    else
                    {
                        float absY = Math.Abs(projectile.velocity.Y);
                        projectile.velocity.X = (3f - absY) * projectile.ai[1];
                    }
                }
            }
        }
예제 #5
0
        public override void AI()
        {
            if (!this.initialized)
            {
                projectile.ai[1]     = Main.rand.Next(2) == 0 ? -1 : 1;
                projectile.ai[0]     = 150;
                projectile.timeLeft -= Main.rand.Next(15);
                projectile.netUpdate = true;
                this.initialized     = true;
            }

            if (projectile.timeLeft <= 550)
            {
                if (projectile.timeLeft == 550)
                {
                    projectile.velocity *= (float)((4 + Main.rand.Next(3)) / 10f);
                    projectile.friendly  = true;
                    projectile.netUpdate = true;
                }
                else
                {
                    Vector2 move     = Vector2.Zero;
                    float   distance = 2000f;
                    int     flag     = -1;
                    for (int k = 0; k < 200; k++)
                    {
                        if (Main.npc[k].active && !Main.npc[k].dontTakeDamage && !Main.npc[k].friendly && Main.npc[k].lifeMax > 5 &&
                            OrchidModAlchemistNPC.AttractiteCanHome(Main.npc[k]))
                        {
                            Vector2 newMove    = Main.npc[k].Center - projectile.Center;
                            float   distanceTo = (float)Math.Sqrt(newMove.X * newMove.X + newMove.Y * newMove.Y);
                            if (distanceTo < distance)
                            {
                                move     = newMove;
                                distance = distanceTo;
                                flag     = k;
                            }
                        }
                    }

                    if (flag > -1)
                    {
                        this.hasTarget = true;

                        float npcPosX  = Main.npc[flag].Center.X;
                        float npcPosY  = Main.npc[flag].Center.Y;
                        float projPosX = projectile.Center.X;
                        float projPosY = projectile.Center.Y;
                        if (Math.Abs(npcPosY - projPosY) > 5f)
                        {
                            if (npcPosY > projPosY)
                            {
                                projectile.velocity.Y += projectile.velocity.X < 5f ? 0.75f : 0f;
                            }
                            else
                            {
                                projectile.velocity.Y -= projectile.velocity.Y > -5f ? 0.75f : 0f;
                            }
                            projectile.velocity.X *= 0.9f;
                        }
                        else
                        {
                            if (npcPosX > projPosX)
                            {
                                projectile.velocity.X += projectile.velocity.X < 8f ? 0.75f : 0f;
                            }
                            else
                            {
                                projectile.velocity.X -= projectile.velocity.X > -8f ? 0.75f : 0f;
                            }
                            projectile.velocity.Y *= 0.9f;
                        }

                        // Vector2 newVel = Main.npc[flag].Center - projectile.Center;
                        // newVel.Normalize();
                        // projectile.ai[0] -= projectile.ai[0] > 0f ? 1f : 0f;
                        // projectile.velocity = newVel.RotatedBy(0.01f * (int)projectile.ai[0] * (int)projectile.ai[1]) * (6f + 0.05f * (int)projectile.ai[0]);

                        if (Main.rand.Next(4) == 0)
                        {
                            int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 16);
                            Main.dust[dust].noGravity = true;
                            Main.dust[dust].noLight   = true;
                            Main.dust[dust].scale    *= 1.5f;
                        }

                        projectile.timeLeft++;
                    }
                    else
                    {
                        this.hasTarget = false;
                        int angle = (int)(5 * projectile.ai[1]);
                        move = projectile.velocity.RotatedBy(MathHelper.ToRadians(angle));
                        move.Normalize();
                        move *= 3f;
                        projectile.velocity = move;
                    }
                }
            }
        }