Ejemplo n.º 1
0
        public override void AI()
        {
            Player      player    = Main.player[projectile.owner];
            VariaPlayer modPlayer = player.GetModPlayer <VariaPlayer>(mod);

            if (player.dead)
            {
                modPlayer.soulBoi = false;
            }
            if (modPlayer.soulBoi)
            {
                projectile.timeLeft = 2;
            }

            projectile.velocity = projectile.DirectionTo(Main.MouseWorld) * (projectile.Distance(Main.MouseWorld) / 8);

            projectile.frameCounter++;
            if (projectile.frameCounter >= 5)
            {
                projectile.frame++;
                projectile.frameCounter = 0;
                if (projectile.frame >= 4)
                {
                    projectile.frame = 0;
                }
            }

            Lighting.AddLight(projectile.position, new Vector3(100, 100, 175) / 200);
        }
Ejemplo n.º 2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (MainTexture == null)
            {
                MainTexture = ModContent.GetTexture("Varia/UI/InfectionBar");
            }
            if (BarTexture == null)
            {
                BarTexture = ModContent.GetTexture("Varia/UI/InfectionBarFill");
            }

            if (MainTexture != null && BarTexture != null)
            {
                Player      player = Main.LocalPlayer;
                VariaPlayer MP     = player.GetModPlayer <VariaPlayer>();
                if (player.GetModPlayer <VariaPlayer>().SeeInfectionBar)
                {
                    Vector2 position = new Vector2(Main.screenWidth / 2 - MainTexture.Width / 2, Main.screenHeight / 2 - 85);
                    // Change Infection and InfectionCap to whatever you have them called in the player file.
                    var length = CalculateLength((int)MP.Infection, (int)MP.InfectionCap, BarTexture.Width);
                    // Order matters. The current order is the fill bar behind the main bar. If you need it in front, swap these.
                    spriteBatch.Draw(MainTexture, position, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
                    spriteBatch.Draw(BarTexture, position + new Vector2(8, 8), new Rectangle(0, 0, length, BarTexture.Height), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
                    // Edit new Vector2(0, 0) with numbers until you fit it exactly where you need it.
                }
            }
        }
Ejemplo n.º 3
0
        public override void AI()
        {
            Player      player    = Main.player[projectile.owner];
            VariaPlayer modPlayer = player.GetModPlayer <VariaPlayer>(mod);

            if (player.dead)
            {
                modPlayer.grimeBaby = false;
            }
            if (modPlayer.grimeBaby)
            {
                projectile.timeLeft = 2;
            }
        }
Ejemplo n.º 4
0
        public override void AI()
        {
            Player      player    = Main.player[projectile.owner];
            VariaPlayer modPlayer = player.GetModPlayer <VariaPlayer>(mod);

            if (player.dead)
            {
                modPlayer.guardianMinion = false;
            }
            if (modPlayer.guardianMinion)
            {
                projectile.timeLeft = 2;
            }

            if (projectile.localAI[0] == 0f)
            {
                AdjustMagnitude(ref projectile.velocity);
                projectile.localAI[0] = 1f;
            }
            Vector2 move     = Vector2.Zero;
            float   distance = 1000f;
            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)
                {
                    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)
            {
                AdjustMagnitude(ref move);
                projectile.velocity = (10 * projectile.velocity + move) / 11f;
                AdjustMagnitude(ref projectile.velocity);
            }
        }
Ejemplo n.º 5
0
        public override void AI()
        {
            for (int i = 0; i < 3; i++)
            {
                Dust dust;
                // You need to set position depending on what you are doing. You may need to subtract width/2 and height/2 as well to center the spawn rectangle.
                Vector2 position = projectile.position;
                dust           = Main.dust[Terraria.Dust.NewDust(position, 30, 30, 197, 0f, 0f, 0, new Color(0, 67, 255), 1.710526f)];
                dust.noGravity = true;
                dust.shader    = GameShaders.Armor.GetSecondaryShader(25, Main.LocalPlayer);
            }

            Player      player    = Main.player[projectile.owner];
            VariaPlayer modPlayer = player.GetModPlayer <VariaPlayer>(mod);

            if (player.dead)
            {
                modPlayer.frostyMist = false;
            }
            if (modPlayer.frostyMist)
            {
                projectile.timeLeft = 2;
            }
        }
Ejemplo n.º 6
0
        public override void AI()
        {
            int spdFrame = 3;

            if (projectile.velocity.X + projectile.velocity.Y / 2 <= 18)
            {
                spdFrame = 4;
            }
            if (projectile.velocity.X + projectile.velocity.Y / 2 <= 15)
            {
                spdFrame = 5;
            }
            if (projectile.velocity.X + projectile.velocity.Y / 2 <= 12)
            {
                spdFrame = 6;
            }

            projectile.frameCounter++;
            if (projectile.frameCounter >= spdFrame)
            {
                projectile.frame++;
                projectile.frameCounter = 0;
                if (projectile.frame >= 4)
                {
                    projectile.frame = 0;
                }
            }

            Player      player    = Main.player[projectile.owner];
            VariaPlayer modPlayer = player.GetModPlayer <VariaPlayer>(mod);

            if (player.dead)
            {
                modPlayer.sharkMinion = false;
            }
            if (modPlayer.sharkMinion)
            {
                projectile.timeLeft = 2;
            }

            projectile.rotation = projectile.velocity.ToRotation() + 3.14159274f;

            float num633 = 700f;
            float num634 = 800f;
            float num635 = 1200f;
            float num636 = 150f;
            float num637 = 0.05f;

            for (int num638 = 0; num638 < 1000; num638++)
            {
                bool flag23 = (Main.projectile[num638].type == mod.ProjectileType("SharkMinion"));
                if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width)
                {
                    if (projectile.position.X < Main.projectile[num638].position.X)
                    {
                        projectile.velocity.X = projectile.velocity.X - num637;
                    }
                    else
                    {
                        projectile.velocity.X = projectile.velocity.X + num637;
                    }
                    if (projectile.position.Y < Main.projectile[num638].position.Y)
                    {
                        projectile.velocity.Y = projectile.velocity.Y - num637;
                    }
                    else
                    {
                        projectile.velocity.Y = projectile.velocity.Y + num637;
                    }
                }
            }
            bool flag24 = false;

            if (projectile.ai[0] == 2f)
            {
                projectile.ai[1]       += 1f;
                projectile.extraUpdates = 1;

                if (projectile.ai[1] > 40f)
                {
                    projectile.ai[1]        = 1f;
                    projectile.ai[0]        = 0f;
                    projectile.extraUpdates = 0;
                    projectile.numUpdates   = 0;
                    projectile.netUpdate    = true;
                }
                else
                {
                    flag24 = true;
                }
            }
            if (flag24)
            {
                return;
            }
            Vector2 vector46 = projectile.position;
            bool    flag25   = false;

            if (projectile.ai[0] != 1f)
            {
                projectile.tileCollide = false;
            }
            if (projectile.tileCollide && WorldGen.SolidTile(Framing.GetTileSafely((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16)))
            {
                projectile.tileCollide = false;
            }
            for (int num645 = 0; num645 < 200; num645++)
            {
                NPC nPC2 = Main.npc[num645];
                if (nPC2.CanBeChasedBy(projectile, false))
                {
                    float num646 = Vector2.Distance(nPC2.Center, projectile.Center);
                    if (((Vector2.Distance(projectile.Center, vector46) > num646 && num646 < num633) || !flag25) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, nPC2.position, nPC2.width, nPC2.height))
                    {
                        num633   = num646;
                        vector46 = nPC2.Center;
                        flag25   = true;
                    }
                }
            }
            float num647 = num634;

            if (flag25)
            {
                num647 = num635;
            }
            if (Vector2.Distance(player.Center, projectile.Center) > num647)
            {
                projectile.ai[0]       = 1f;
                projectile.tileCollide = false;
                projectile.netUpdate   = true;
            }
            if (flag25 && projectile.ai[0] == 0f)
            {
                Vector2 vector47 = vector46 - projectile.Center;
                float   num648   = vector47.Length();
                vector47.Normalize();
                if (num648 > 200f)
                {
                    float scaleFactor2 = 8f;
                    vector47           *= scaleFactor2;
                    projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
                }
                else
                {
                    float num649 = 4f;
                    vector47           *= -num649;
                    projectile.velocity = (projectile.velocity * 40f + vector47) / 41f;
                }
            }
            else
            {
                bool flag26 = false;
                if (!flag26)
                {
                    flag26 = (projectile.ai[0] == 1f);
                }
                float num650 = 6f;
                if (flag26)
                {
                    num650 = 15f;
                }
                Vector2 center2  = projectile.Center;
                Vector2 vector48 = player.Center - center2 + new Vector2(0f, -60f);
                float   num651   = vector48.Length();
                if (num651 > 200f && num650 < 8f)
                {
                    num650 = 8f;
                }
                if (num651 < num636 && flag26 && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
                {
                    projectile.ai[0]     = 0f;
                    projectile.netUpdate = true;
                }
                if (num651 > 2000f)
                {
                    projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2);
                    projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2);
                    projectile.netUpdate  = true;
                }
                if (num651 > 70f)
                {
                    vector48.Normalize();
                    vector48           *= num650;
                    projectile.velocity = (projectile.velocity * 40f + vector48) / 41f;
                }
                else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
                {
                    projectile.velocity.X = -0.15f;
                    projectile.velocity.Y = -0.05f;
                }
            }
            if (projectile.ai[1] > 0f)
            {
                projectile.ai[1] += (float)Main.rand.Next(1, 4);
            }
            if (projectile.ai[1] > 40f)
            {
                projectile.ai[1]     = 0f;
                projectile.netUpdate = true;
            }
            if (projectile.ai[0] == 0f)
            {
                if (projectile.ai[1] == 0f && flag25 && num633 < 500f)
                {
                    projectile.ai[1] += 1f;
                    if (Main.myPlayer == projectile.owner)
                    {
                        projectile.ai[0] = 2f;
                        Vector2 value20 = vector46 - projectile.Center;
                        value20.Normalize();
                        projectile.velocity  = value20 * 8f;
                        projectile.netUpdate = true;
                        return;
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public override void AI()
        {
            projectile.frameCounter++;
            if (projectile.frameCounter >= 4)
            {
                projectile.frame++;
                projectile.frameCounter = 0;
                if (projectile.frame >= 7)
                {
                    projectile.frame = 0;
                }
            }

            Player      player    = Main.player[projectile.owner];
            VariaPlayer modPlayer = player.GetModPlayer <VariaPlayer>(mod);

            if (player.dead)
            {
                modPlayer.ForgottenSpirit = false;
            }
            if (modPlayer.ForgottenSpirit)
            {
                projectile.timeLeft = 2;
            }

            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.ai[1]++;

            bool isTargetingNPC = false;

            if (Methods.ClosestNPC(ref target, 900, projectile.Center))
            {
                isTargetingNPC = true;
            }

            Vector2 flyTo;

            if (!isTargetingNPC)
            {
                flyTo = Main.player[projectile.owner].Center - new Vector2(0, 50 + 35 * (projectile.minionPos));
            }
            else
            {
                flyTo = target.Center;
            }

            projectile.velocity += projectile.DirectionTo(flyTo) * projectile.Distance(flyTo) / 350;
            if (projectile.velocity.X >= 14)
            {
                projectile.velocity.X = 14;
            }
            if (projectile.velocity.X <= -14)
            {
                projectile.velocity.X = -14;
            }
            if (projectile.velocity.Y >= 14)
            {
                projectile.velocity.Y = 14;
            }
            if (projectile.velocity.Y <= -14)
            {
                projectile.velocity.Y = -14;
            }

            if (Main.rand.NextFloat() < 1f)
            {
                Dust    dust;
                Vector2 position = Main.LocalPlayer.Center;
                dust = Main.dust[Terraria.Dust.NewDust(projectile.position, projectile.width, projectile.height, 206, 0f, 2.105263f, 0, new Color(255, 255, 255), 0.6578947f)];
            }

            if (projectile.Distance(flyTo) > 5000 && !isTargetingNPC)
            {
                projectile.position = flyTo;
            }
        }