public override bool PreAI()
        {
            projectile.ai[1] += 1f;
            bool chasing = false;

            if (projectile.ai[1] >= 30f)
            {
                chasing = true;

                projectile.friendly = true;
                NPC target = null;
                if (projectile.ai[0] == -1f)
                {
                    target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false);
                }
                else
                {
                    target = Main.npc[(int)projectile.ai[0]];
                    if (!target.active || !target.CanBeChasedBy())
                    {
                        target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false);
                    }
                }

                if (target == null)
                {
                    chasing          = false;
                    projectile.ai[0] = -1f;
                }
                else
                {
                    projectile.ai[0] = (float)target.whoAmI;
                    ProjectileExtras.HomingAI(this, target, 10f, 5f);
                }
            }

            ProjectileExtras.LookAlongVelocity(this);
            if (!chasing)
            {
                Vector2 dir = projectile.velocity;
                float   vel = projectile.velocity.Length();
                if (vel != 0f)
                {
                    if (vel < 4f)
                    {
                        dir *= 1 / vel;
                        projectile.velocity += dir * 0.0625f;
                    }
                }
                else
                {
                    //Stops the projectiles from spazzing out
                    projectile.velocity.X += Main.rand.Next(2) == 0 ? 0.1f : -0.1f;
                }
            }
            {
                int dust = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 75, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f);
            }
            return(false);
        }
Esempio n. 2
0
 public override void AI()
 {
     if (projectile.localAI[0] == 0f)
     {
         ProjectileExtras.LookAlongVelocity(this);
         projectile.localAI[0] = 1f;
     }
     if (Main.rand.NextDouble() < 0.5)
     {
         Dust dust = Dust.NewDustDirect(projectile.position - new Vector2(4, 4), projectile.width + 8, projectile.height + 8, ModContent.DustType <Wind>());
         dust.velocity   = projectile.velocity * 0.2f;
         dust.customData = new WindAnchor(projectile.Center, projectile.velocity, dust.position);
     }
 }
Esempio n. 3
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (player.active && Offset >= 0)
            {
                projectile.penetrate = 1;
                MyPlayer modPlayer = player.GetModPlayer <MyPlayer>();
                if (player.whoAmI == Main.myPlayer && modPlayer.glyph != GlyphType.Frost)
                {
                    projectile.Kill();
                    return;
                }

                projectile.timeLeft = 300;
                modPlayer.frostTally++;
                int   count    = modPlayer.frostCount;
                float sector   = MathHelper.TwoPi / (count > 0 ? count : 1);
                float rotation = modPlayer.frostRotation + Offset * sector;
                if (rotation > MathHelper.TwoPi)
                {
                    rotation -= MathHelper.TwoPi;
                }
                float delta = projectile.rotation;
                if (delta > MathHelper.Pi)
                {
                    delta -= MathHelper.TwoPi;
                }
                else if (delta < -MathHelper.Pi)
                {
                    delta += MathHelper.TwoPi;
                }
                delta = rotation - delta;
                if (delta > MathHelper.Pi)
                {
                    delta -= MathHelper.TwoPi;
                }
                else if (delta < -MathHelper.Pi)
                {
                    delta += MathHelper.TwoPi;
                }
                if (delta > 1.5 * TURNRATE)
                {
                    projectile.rotation += 1.5f * TURNRATE;
                }
                else if (delta < .5 * TURNRATE)
                {
                    projectile.rotation += 0.5f * TURNRATE;
                }
                else
                {
                    projectile.rotation = rotation;
                }
                projectile.Center = player.MountedCenter + new Vector2(0, -OFFSET).RotatedBy(projectile.rotation);
                return;
            }
            //else if (Offset < 0)
            //{
            //	if (!projectile.velocity.Nearing(Target - projectile.Center))
            //	{
            //		projectile.position = Target;
            //		projectile.Kill();
            //		return;
            //	}
            //}

            if (projectile.localAI[1] == 0)
            {
                projectile.localAI[1] = 1;
                ProjectileExtras.LookAlongVelocity(this);
                projectile.penetrate    = -1;
                projectile.extraUpdates = 1;
                projectile.tileCollide  = true;
            }
        }
Esempio n. 4
0
        public override void AI()
        {
            if (projectile.ai[1] == 0)
            {
                projectile.ai[0] = -1;
            }

            projectile.ai[1] += 1f;
            bool chasing = false;

            if (projectile.ai[1] >= 30f)
            {
                chasing = true;

                projectile.friendly = true;
                NPC target = null;
                if (projectile.ai[0] < 0 || projectile.ai[0] >= Main.maxNPCs)
                {
                    target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false);
                }
                else
                {
                    target = Main.npc[(int)projectile.ai[0]];
                    if (!target.active || !target.CanBeChasedBy())
                    {
                        target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false);
                    }
                }

                if (target == null)
                {
                    chasing          = false;
                    projectile.ai[0] = -1f;
                }
                else
                {
                    projectile.ai[0] = (float)target.whoAmI;
                    ProjectileExtras.HomingAI(this, target, 10f, .5f);
                }
            }

            ProjectileExtras.LookAlongVelocity(this);
            if (!chasing)
            {
                Vector2 dir = projectile.velocity;
                float   vel = projectile.velocity.Length();
                if (vel != 0f)
                {
                    if (vel < 8f)
                    {
                        dir *= 1 / vel;
                        projectile.velocity += dir * 0.0625f;
                    }
                }
                else
                {
                    //Stops the projectile from spazzing out
                    projectile.velocity.X += Main.rand.Next(2) == 0 ? 0.1f : -0.1f;
                }
            }

            for (int i = 0; i < 10; i++)
            {
                Vector2 pos = projectile.Center - projectile.velocity * ((float)i / 10f);
                int     num = Dust.NewDust(pos, 2, 2, DustID.SilverCoin);
                Main.dust[num].alpha = projectile.alpha;
                //Main.dust[num].position = pos;
                Main.dust[num].velocity  = Vector2.Zero;
                Main.dust[num].noGravity = true;
            }
        }
Esempio n. 5
0
        public override bool PreAI()
        {
            projectile.ai[1] += 1f;
            bool chasing = false;

            if (projectile.ai[1] >= 30f)
            {
                chasing = true;

                projectile.friendly = true;
                NPC target = null;
                if (projectile.ai[0] == -1f)
                {
                    target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false);
                }
                else
                {
                    target = Main.npc[(int)projectile.ai[0]];
                    if (!target.active || !target.CanBeChasedBy())
                    {
                        target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false);
                    }
                }

                if (target == null)
                {
                    chasing          = false;
                    projectile.ai[0] = -1f;
                }
                else
                {
                    projectile.ai[0] = (float)target.whoAmI;
                    ProjectileExtras.HomingAI(this, target, 10f, 5f);
                }
            }

            ProjectileExtras.LookAlongVelocity(this);
            if (!chasing)
            {
                Vector2 dir = projectile.velocity;
                float   vel = projectile.velocity.Length();
                if (vel != 0f)
                {
                    if (vel < 4f)
                    {
                        dir *= 1 / vel;
                        projectile.velocity += dir * 0.0625f;
                    }
                }
                else
                {
                    //Stops the projectiles from spazzing out
                    projectile.velocity.X += Main.rand.Next(2) == 0 ? 0.1f : -0.1f;
                }
            }

            int num = 5;

            for (int k = 0; k < 3; k++)
            {
                int index2 = Dust.NewDust(projectile.position, 1, 1, DustID.DungeonWater, 0.0f, 0.0f, 0, new Color(), 1f);
                Main.dust[index2].position  = projectile.Center - projectile.velocity / num * (float)k;
                Main.dust[index2].scale     = .5f;
                Main.dust[index2].velocity *= 0f;
                Main.dust[index2].noGravity = true;
                Main.dust[index2].noLight   = false;
            }

            return(false);
        }