Esempio n. 1
0
        public override void AI()
        {
            projectile.velocity  = new Vector2(0, 0);
            projectile.timeLeft -= (int)projectile.ai[0] - 1;
            //Player player = Main.player[projectile.owner];

            for (int p = 0; p < 255; p++)
            {
                direction = (projectile.Center - Main.player[p].Center).ToRotation();
                horiSpeed = (float)Math.Cos(direction) * pullSpeed / 2;
                vertSpeed = (float)Math.Sin(direction) * pullSpeed / 2;
                Main.player[p].velocity += new Vector2(horiSpeed, vertSpeed);

                for (int i = 0; i < 1; i++)
                {
                    int dust = Dust.NewDust(Main.player[p].position, Main.player[p].width, Main.player[p].height, mod.DustType("B4PDust"), 0, 0);
                }
            }

            /*
             * for (int g = 0; g < 3; g++)
             * {
             *  Dust blackEs = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("B4PDust"), 0, 0)];
             *  direction = (projectile.Center - blackEs.position).ToRotation();
             *  horiSpeed = (float)Math.Cos(direction) * pullSpeed * 50;
             *  vertSpeed = (float)Math.Sin(direction) * pullSpeed * 50;
             *  blackEs.velocity += new Vector2(horiSpeed, vertSpeed);
             *
             *
             * }
             */

            for (int d = 0; d < 80; d++)
            {
                float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);
                Dust  dust  = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(Main.rand.NextFloat(10, 200), theta), mod.DustType("BlackHoleMatter"), QwertyMethods.PolarVector(6, theta + (float)Math.PI / 2));
                dust.scale = 1f;
            }

            for (int i = 0; i < Main.dust.Length; i++)
            {
                dust = Main.dust[i];
                if (!dust.noGravity)
                {
                    direction      = (projectile.Center - dust.position).ToRotation();
                    horiSpeed      = (float)Math.Cos(direction) * pullSpeed * 5;
                    vertSpeed      = (float)Math.Sin(direction) * pullSpeed * 5;
                    dust.velocity += new Vector2(horiSpeed, vertSpeed);
                }
                if (dust.type == mod.DustType("BlackHoleMatter"))
                {
                    direction      = (projectile.Center - dust.position).ToRotation();
                    dust.velocity += QwertyMethods.PolarVector(.8f, direction);
                    if ((dust.position - projectile.Center).Length() < 10)
                    {
                        dust.scale = 0f;
                    }
                    else
                    {
                        dust.scale = .35f;
                    }
                }
            }
            for (int i = 0; i < 200; i++)
            {
                mass = Main.npc[i];
                if (!mass.boss && mass.active && mass.knockBackResist != 0f)
                {
                    direction      = (projectile.Center - mass.Center).ToRotation();
                    horiSpeed      = (float)Math.Cos(direction) * pullSpeed;
                    vertSpeed      = (float)Math.Sin(direction) * pullSpeed;
                    mass.velocity += new Vector2(horiSpeed, vertSpeed);
                    for (int g = 0; g < 1; g++)
                    {
                        int dust = Dust.NewDust(mass.position, mass.width, mass.height, mod.DustType("B4PDust"), horiSpeed * dustSpeed, vertSpeed * dustSpeed);
                    }
                }
            }
            for (int i = 0; i < Main.item.Length; i++)
            {
                item = Main.item[i];
                if (item.position != new Vector2(0, 0))
                {
                    direction      = (projectile.Center - item.Center).ToRotation();
                    horiSpeed      = (float)Math.Cos(direction) * pullSpeed;
                    vertSpeed      = (float)Math.Sin(direction) * pullSpeed;
                    item.velocity += new Vector2(horiSpeed, vertSpeed);
                    for (int g = 0; g < 1; g++)
                    {
                        int dust = Dust.NewDust(item.position, item.width, item.height, mod.DustType("B4PDust"), horiSpeed * dustSpeed, vertSpeed * dustSpeed);
                    }
                }
            }
            for (int i = 0; i < Main.projectile.Length; i++)
            {
                proj = Main.projectile[i];
                if (proj.active && proj.type != mod.ProjectileType("BlackHole") && proj.type != mod.ProjectileType("SideLaser"))
                {
                    direction      = (projectile.Center - proj.Center).ToRotation();
                    horiSpeed      = (float)Math.Cos(direction) * pullSpeed;
                    vertSpeed      = (float)Math.Sin(direction) * pullSpeed;
                    proj.velocity += new Vector2(horiSpeed, vertSpeed);
                    for (int g = 0; g < 1; g++)
                    {
                        int dust = Dust.NewDust(proj.position, proj.width, proj.height, mod.DustType("B4PDust"), horiSpeed * dustSpeed, vertSpeed * dustSpeed);
                    }
                }
            }
        }
Esempio n. 2
0
        public override void Kill(int timeLeft)
        {
            Main.PlaySound(SoundID.Item14, projectile.position);
            projectile.position.X = projectile.position.X + (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2);
            projectile.width      = 22;
            projectile.height     = 22;
            projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
            projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
            for (int num761 = 0; num761 < 20; num761++)
            {
                int num762 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 1.5f);
                Main.dust[num762].velocity *= 1.4f;
            }
            for (int num763 = 0; num763 < 10; num763++)
            {
                int num764 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 2.5f);
                Main.dust[num764].noGravity = true;
                Main.dust[num764].velocity *= 5f;
                num764 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 1.5f);
                Main.dust[num764].velocity *= 3f;
            }
            int num765 = Gore.NewGore(new Vector2(projectile.position.X, projectile.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);

            Main.gore[num765].velocity *= 0.4f;
            Gore expr_18B0E_cp_0 = Main.gore[num765];

            expr_18B0E_cp_0.velocity.X = expr_18B0E_cp_0.velocity.X + 1f;
            Gore expr_18B2E_cp_0 = Main.gore[num765];

            expr_18B2E_cp_0.velocity.Y = expr_18B2E_cp_0.velocity.Y + 1f;
            num765 = Gore.NewGore(new Vector2(projectile.position.X, projectile.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
            Main.gore[num765].velocity *= 0.4f;
            Gore expr_18BB2_cp_0 = Main.gore[num765];

            expr_18BB2_cp_0.velocity.X = expr_18BB2_cp_0.velocity.X - 1f;
            Gore expr_18BD2_cp_0 = Main.gore[num765];

            expr_18BD2_cp_0.velocity.Y = expr_18BD2_cp_0.velocity.Y + 1f;
            num765 = Gore.NewGore(new Vector2(projectile.position.X, projectile.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
            Main.gore[num765].velocity *= 0.4f;
            Gore expr_18C56_cp_0 = Main.gore[num765];

            expr_18C56_cp_0.velocity.X = expr_18C56_cp_0.velocity.X + 1f;
            Gore expr_18C76_cp_0 = Main.gore[num765];

            expr_18C76_cp_0.velocity.Y = expr_18C76_cp_0.velocity.Y - 1f;
            num765 = Gore.NewGore(new Vector2(projectile.position.X, projectile.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
            Main.gore[num765].velocity *= 0.4f;
            Gore expr_18CFA_cp_0 = Main.gore[num765];

            expr_18CFA_cp_0.velocity.X = expr_18CFA_cp_0.velocity.X - 1f;
            Gore expr_18D1A_cp_0 = Main.gore[num765];

            expr_18D1A_cp_0.velocity.Y = expr_18D1A_cp_0.velocity.Y - 1f; Main.PlaySound(SoundID.Item62, projectile.position);
            for (int i = 0; i < 2; i++)
            {
                Projectile meteor = Main.projectile[Projectile.NewProjectile(projectile.Center + new Vector2(Main.rand.Next(-20, 20), -1000), QwertyMethods.PolarVector(10, (float)Math.PI / 2 + (float)Math.PI / 16 * Main.rand.NextFloat(-1, 1)), 424 + Main.rand.Next(2), (int)(projectile.damage), projectile.knockBack, projectile.owner, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f)];
                meteor.magic  = false;
                meteor.thrown = true;

                if (Main.netMode == 1)
                {
                    QwertysRandomContent.UpdateProjectileClass(meteor);
                }
            }
        }
Esempio n. 3
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Player drawPlayer = Main.LocalPlayer;
            float  scale      = 32;

            if (projectile.ai[1] > 300)
            {
                scale = 12;
            }



            int height = (int)(Main.screenHeight / scale);
            int width  = (int)(Main.screenWidth / scale);

            height++;
            Texture2D      TheShadow  = new Texture2D(Main.graphics.GraphicsDevice, width, height);
            var            dataColors = new Color[width * height];
            List <Vector3> lightSpots = new List <Vector3>();

            lightSpots.Add(new Vector3(drawPlayer.Center.X, drawPlayer.Center.Y, projectile.ai[1]));
            if (!Main.gamePaused)
            {
                lightSpots.Add(new Vector3(Main.MouseWorld.X, Main.MouseWorld.Y, 80));
            }

            NPC master = Main.npc[(int)projectile.ai[0]];

            if (master.ai[3] > 0)
            {
                lightSpots.Add(new Vector3(master.Center.X, master.Center.Y, master.ai[3]));
            }
            for (int p = 0; p < 1000; p++)
            {
                if (Main.projectile[p].active && Main.projectile[p].type == mod.ProjectileType("Cannon") && Main.projectile[p].timeLeft > 30)
                {
                    //Main.NewText("HI");
                    if (Main.projectile[p].timeLeft > 30)
                    {
                        float r = 0;
                        if (Main.projectile[p].timeLeft > 60)
                        {
                            r  = 90 - Main.projectile[p].timeLeft;
                            r *= 2;
                        }
                        else
                        {
                            r  = Main.projectile[p].timeLeft - 30;
                            r *= 2;
                        }
                        lightSpots.Add(new Vector3(Main.projectile[p].Center.X, Main.projectile[p].Center.Y, r));
                    }
                }

                if (Main.projectile[p].active && Main.projectile[p].type == mod.ProjectileType("BloodforceCatalyst"))
                {
                    if (Main.projectile[p].timeLeft > 20)
                    {
                        int f = 40;
                        if (Main.projectile[p].timeLeft > 40)
                        {
                            f  = 60 - Main.projectile[p].timeLeft;
                            f *= 2;
                        }
                        for (int i = 0; i < 4; i++)
                        {
                            Vector2 offset = Main.projectile[p].Center + QwertyMethods.PolarVector(Main.projectile[p].ai[1], Main.projectile[p].rotation + (float)Math.PI * i / 2);
                            lightSpots.Add(new Vector3(offset.X, offset.Y, f));
                        }
                    }
                    else
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            Vector2 offset = Main.projectile[p].Center + QwertyMethods.PolarVector(Main.projectile[p].ai[1], Main.projectile[p].rotation + (float)Math.PI * i / 2);
                            lightSpots.Add(new Vector3(offset.X, offset.Y, Main.projectile[p].timeLeft * 2));
                        }
                    }
                }
                if (Main.projectile[p].active && Main.projectile[p].type == mod.ProjectileType("Tripwire"))
                {
                    if (Main.projectile[p].ai[1] < 60)
                    {
                        for (int d = 0; d < 2; d++)
                        {
                            Vector2 Cen = Main.projectile[p].Center + QwertyMethods.PolarVector(Main.projectile[p].ai[1] * 7, Main.projectile[p].rotation + (float)Math.PI * d);
                            float   r   = 60;
                            if (Main.projectile[p].ai[1] > 50)
                            {
                                r = 60 - (Main.projectile[p].ai[1] - 50) * 6;
                            }
                            else if (Main.projectile[p].ai[1] < 10)
                            {
                                r = (Main.projectile[p].ai[1]) * 6;
                            }

                            lightSpots.Add(new Vector3(Cen.X, Cen.Y, r));
                        }
                    }
                }
            }
            for (int i = 0; i < lightSpots.Count; i++)
            {
                lightSpots[i] = new Vector3(lightSpots[i].X - 4, lightSpots[i].Y - 4, lightSpots[i].Z);
            }

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    bool check = false;
                    foreach (Vector3 spot in lightSpots)
                    {
                        if (((new Vector2(spot.X, spot.Y) - Main.screenPosition) / scale - (new Vector2(x, y))).Length() < (spot.Z + scale) / scale)
                        {
                            check = true;
                            break;
                        }
                    }
                    if (!check)
                    {
                        dataColors[x + y * width] = Color.Black;
                    }
                }
            }
            TheShadow.SetData(0, null, dataColors, 0, width * height);
            //Main.NewText("Big: " + dataColors.Length);
            //Precise darkening, Save the smaller pixels for when closer to a thing you need to reveal for better performance
            spriteBatch.Draw(TheShadow, new Vector2(0, 0), null, Color.White, 0f, new Vector2(0, 0), scale, 0, 0);
            if (scale > 12)
            {
                foreach (Vector3 hr in lightSpots)
                {
                    scale  = 12f;
                    width  = (int)((hr.Z + scale * 8) * 2f / scale);
                    height = width;
                    if (width < Main.screenWidth / scale || height < Main.screenHeight / scale)
                    {
                        TheShadow  = new Texture2D(Main.graphics.GraphicsDevice, width, height);
                        dataColors = new Color[width * height];
                        Vector2 pos = new Vector2(hr.X, hr.Y) - Main.screenPosition - new Vector2(width, height) * scale / 2f;
                        //pos /= scale;
                        for (int x = 0; x < width; x++)
                        {
                            for (int y = 0; y < height; y++)
                            {
                                bool check = false;
                                foreach (Vector3 spot in lightSpots)
                                {
                                    if (((new Vector2(spot.X, spot.Y) - Main.screenPosition) / scale - (new Vector2(x, y) + pos / scale)).Length() < spot.Z / scale)
                                    {
                                        check = true;
                                        break;
                                    }
                                }
                                if (!check)
                                {
                                    dataColors[x + y * width] = Color.Black;
                                }
                            }
                        }
                        TheShadow.SetData(0, null, dataColors, 0, width * height);
                        // Main.NewText("Precise: " + dataColors.Length)
                        spriteBatch.Draw(TheShadow, pos + new Vector2(scale, scale) * .5f, null, Color.White, 0f, new Vector2(0, 0), scale, 0, 0);
                    }
                }
            }

            return(false);
        }
        public override void AI()
        {
            if (runOnce)
            {
                npc.rotation = npc.ai[0];
                runOnce      = false;
            }
            npc.TargetClosest(false);
            Player player = Main.player[npc.target];

            BladeStart = npc.Center + QwertyMethods.PolarVector(HiltLength / 2, npc.rotation + (float)Math.PI / 2);
            BladeTip   = npc.Center + QwertyMethods.PolarVector((HiltLength / 2) + BladeLength, npc.rotation + (float)Math.PI / 2);
            timer++;
            //npc.rotation += (float)Math.PI / 60;

            if (swing)
            {
                if (toEndPoint)
                {
                    npc.velocity = (endPoint - npc.Center) * acceleration;
                    if ((npc.Center - endPoint).Length() < 100)
                    {
                        swing      = false;
                        toEndPoint = false;
                    }
                }
                else
                {
                    npc.velocity = (hitPoint - npc.Center) * acceleration;
                    if ((npc.Center - hitPoint).Length() < 100)
                    {
                        toEndPoint = true;
                    }
                }
                if (npc.velocity.Length() > maxSpeed)
                {
                    npc.velocity = npc.velocity.SafeNormalize(-Vector2.UnitY) * maxSpeed;
                }
                if (player.Center.X > npc.Center.X)
                {
                    npc.rotation = QwertyMethods.SlowRotation(npc.rotation, npc.velocity.ToRotation() + (float)Math.PI, 4);
                }
                else
                {
                    npc.rotation = QwertyMethods.SlowRotation(npc.rotation, npc.velocity.ToRotation(), 4);
                }
            }
            else if (endIntro)
            {
                //npc.rotation += (float)Math.PI / 60;
                if (npc.Center.Y + 400 < player.Center.Y)
                {
                    npc.velocity = Vector2.Zero;
                    hitPoint     = player.Center;
                    if (player.Center.X > npc.Center.X)
                    {
                        hitPoint.X -= BladeLength / 2;
                    }
                    else
                    {
                        hitPoint.X += BladeLength / 2;
                    }
                    endPoint    = hitPoint;
                    endPoint.Y += 400;
                    swing       = true;
                }
                else
                {
                    npc.rotation = QwertyMethods.SlowRotation(npc.rotation, (float)Math.PI, 4);
                    npc.velocity = new Vector2(0, -8);
                }
            }
            else
            {
                npc.rotation = npc.ai[0];
                npc.velocity = QwertyMethods.PolarVector(20, npc.ai[0] + (float)Math.PI / 2);
            }

            float goTo = ((npc.Center - player.Center).ToRotation() + (float)Math.PI / 2);

            goTo         = QwertyMethods.PolarVector(1, goTo).ToRotation();
            npc.rotation = QwertyMethods.PolarVector(1, npc.rotation).ToRotation();

            if (Math.Abs(npc.rotation - goTo) > (float)Math.PI / 2)
            {
                endIntro = true;
            }
        }
Esempio n. 5
0
        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            float point = 0f;

            return(shootTimer > 180 && Collision.CheckAABBvLineCollision(targetHitbox.Location.ToVector2(), targetHitbox.Size(), projectile.Center, projectile.Center + QwertyMethods.PolarVector(laserLength, projectile.rotation), 10, ref point));
        }
Esempio n. 6
0
        public override void PostItemCheck()
        {
            if (!player.inventory[player.selectedItem].IsAir)
            {
                Point origin = player.Bottom.ToTileCoordinates();
                Point point;
                Item  item = player.inventory[player.selectedItem];
                //Main.NewText(player.itemAnimation  + " / " + player.itemAnimationMax);

                if (item.useStyle == 101)
                {
                    if (Main.mouseRight && Main.myPlayer == item.owner && !hasRightClicked)
                    {
                        if (WorldUtils.Find(origin, Searches.Chain(new Searches.Down(3), new GenCondition[]
                        {
                            new Conditions.IsSolid()
                        }), out point))
                        {
                            player.itemAnimation = player.itemAnimationMax;
                            player.velocity.Y    = -10 - player.jumpSpeedBoost;
                            uppercut             = true;
                            slam = false;
                        }
                        else
                        {
                            player.velocity.Y = 10;
                            slam     = true;
                            uppercut = false;
                        }
                    }
                    float shift = 0f;
                    if (player.itemAnimation > 0 && uppercut || slam)
                    {
                        if (slam)
                        {
                            //Main.NewText("Slamming");
                            player.bodyFrame.Y = player.bodyFrame.Height * 4;
                            shift = (float)Math.PI / 2;

                            if (player.velocity.Y != 0)
                            {
                                player.itemAnimation = 2;
                            }
                            else
                            {
                                player.itemAnimation = 0;
                                slam = false;
                            }
                        }
                        else if (uppercut)
                        {
                            shift = (float)Math.PI / 2 * ((float)player.itemAnimation / (float)player.itemAnimationMax) - (float)Math.PI / 4;

                            if (player.itemAnimation < player.itemAnimationMax * .5f)
                            {
                                player.bodyFrame.Y = player.bodyFrame.Height * 2;
                            }
                            else if (player.itemAnimation < player.itemAnimationMax * .25f)
                            {
                                player.bodyFrame.Y = player.bodyFrame.Height * 3;
                            }
                            else
                            {
                                player.bodyFrame.Y = player.bodyFrame.Height * 4;
                            }
                            if (player.itemAnimation < 2)
                            {
                                player.itemAnimation = 2;
                            }
                            if (player.velocity.Y >= 0)
                            {
                                player.itemAnimation = 0;
                                uppercut             = false;
                            }
                        }
                    }
                    else
                    {
                        if (player.itemAnimation < player.itemAnimationMax * .25f)
                        {
                            shift = (float)Math.PI / -4 * ((player.itemAnimation) / (player.itemAnimationMax * .25f));
                        }
                        else if (player.itemAnimation < player.itemAnimationMax * .75f)
                        {
                            shift = (float)Math.PI / -2 * (1 - (player.itemAnimation - (player.itemAnimationMax * .25f)) / (player.itemAnimationMax * .5f)) + (float)Math.PI / 4;
                        }
                        else
                        {
                            shift = (float)Math.PI / 4 * (1 - (player.itemAnimation - (player.itemAnimationMax * .75f)) / (player.itemAnimationMax * .25f));
                        }
                        if (player.itemAnimation < player.itemAnimationMax * .15f)
                        {
                            player.bodyFrame.Y = player.bodyFrame.Height * 3;
                        }
                        else if (player.itemAnimation < player.itemAnimationMax * .35f)
                        {
                            player.bodyFrame.Y = player.bodyFrame.Height * 2;
                        }
                        else if (player.itemAnimation < player.itemAnimationMax * .65f)
                        {
                            player.bodyFrame.Y = player.bodyFrame.Height * 3;
                        }
                        else if (player.itemAnimation < player.itemAnimationMax * .85f)
                        {
                            player.bodyFrame.Y = player.bodyFrame.Height * 4;
                        }
                        else
                        {
                            player.bodyFrame.Y = player.bodyFrame.Height * 3;
                        }
                    }
                    if (Main.mouseRight && Main.myPlayer == item.owner && !slam && !uppercut)
                    {
                        player.itemAnimation = 0;
                    }

                    player.itemRotation = (float)Math.PI / -4 + player.direction * ((float)Math.PI / 2 + shift);
                    //Main.NewText(MathHelper.ToDegrees(player.itemRotation));

                    Vector2 vector24 = Main.OffsetsPlayerOnhand[player.bodyFrame.Y / 56] * 2f;
                    if (player.direction != 1)
                    {
                        vector24.X = (float)player.bodyFrame.Width - vector24.X;
                    }
                    if (player.gravDir != 1f)
                    {
                        vector24.Y = (float)player.bodyFrame.Height - vector24.Y;
                    }
                    vector24           -= new Vector2((float)(player.bodyFrame.Width - player.width), (float)(player.bodyFrame.Height - 42)) / 2f;
                    player.itemLocation = player.position + vector24;

                    float swordLength = new Vector2(Main.itemTexture[item.type].Width, Main.itemTexture[item.type].Height).Length();
                    swordLength *= item.scale;
                    for (int n = 0; n < Main.npc.Length; n++)
                    {
                        localNPCImmunity[n]--;
                        if (Main.npc[n].active && !Main.npc[n].dontTakeDamage && (!Main.npc[n].friendly || (Main.npc[n].type == 22 && player.killGuide) || (Main.npc[n].type == 54 && player.killClothier)) && player.itemAnimation > 0 && localNPCImmunity[n] <= 0 && Collision.CheckAABBvLineCollision(Main.npc[n].position, Main.npc[n].Size, player.itemLocation, player.itemLocation + QwertyMethods.PolarVector(swordLength, player.itemRotation - (float)Math.PI / 4)))
                        {
                            localNPCImmunity[n] = item.useAnimation / 3;
                            int damageBeforeVariance = item.damage;
                            if (item.melee)
                            {
                                damageBeforeVariance = (int)((float)item.damage * player.meleeDamage);
                            }
                            if (item.ranged)
                            {
                                damageBeforeVariance = (int)((float)item.damage * player.rangedDamage);
                            }
                            if (item.magic)
                            {
                                damageBeforeVariance = (int)((float)item.damage * player.magicDamage);
                            }
                            if (item.summon)
                            {
                                damageBeforeVariance = (int)((float)item.damage * player.minionDamage);
                            }
                            if (item.thrown)
                            {
                                damageBeforeVariance = (int)((float)item.damage * player.thrownDamage);
                            }
                            if (slam || uppercut)
                            {
                                damageBeforeVariance *= 2;
                            }
                            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(3), new GenCondition[]
                            {
                                new Conditions.IsSolid()
                            }), out point) && player.GetModPlayer <SkywardHiltEffect>().effect&& player.grappling[0] == -1)
                            {
                                damageBeforeVariance *= 2;
                            }
                            //////////////////////

                            Projectile p = QwertyMethods.PokeNPC(player, Main.npc[n], damageBeforeVariance, item.knockBack, true);
                            if (item.type == mod.ItemType("EtimsSword"))
                            {
                                p.GetGlobalProjectile <Etims>().effect = true;
                            }
                        }
                    }
                    hasRightClicked = (Main.mouseRight && Main.myPlayer == item.owner);
                }
            }
        }
Esempio n. 7
0
        public override void AI()
        {
            if (justTeleported)
            {
                justTeleported = false;
            }
            if (runOnce)
            {
                if (Main.netMode != 1)
                {
                    npc.ai[2]     = npc.Center.X;
                    npc.ai[3]     = npc.Center.Y;
                    npc.netUpdate = true;
                }
                runOnce = false;
            }
            Player player = Main.player[npc.target];

            //parent = Main.npc[(int)npc.ai[0]];
            if (!player.active || player.dead)
            {
                npc.TargetClosest(false);
                player = Main.player[npc.target];
                if (!player.active || player.dead)
                {
                    npc.velocity = new Vector2(0f, 10f);
                    if (npc.timeLeft > 1)
                    {
                        npc.timeLeft = 1;
                    }
                    return;
                }
            }
            timer++;
            if (timer > waitTime + chargeTime)
            {
                for (int i = 0; i < minionRingDustQty; i++)
                {
                    float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);

                    Dust dust = Dust.NewDustPerfect(npc.Center + QwertyMethods.PolarVector(minionRingRadius, theta), mod.DustType("AncientGlow"), QwertyMethods.PolarVector(-minionRingRadius / 10, theta));
                    dust.noGravity = true;
                }
                if (Main.netMode != 1)
                {
                    npc.ai[1]     = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);
                    npc.netUpdate = true;
                }
                moveTo = new Vector2(player.Center.X + (float)Math.Cos(npc.ai[1]) * 600, player.Center.Y + (float)Math.Sin(npc.ai[1]) * 350);
                if (Main.netMode != 1)
                {
                    npc.ai[2]     = moveTo.X;
                    npc.ai[3]     = moveTo.Y;
                    npc.netUpdate = true;
                }
                justTeleported = true;
                timer          = 0;
            }
            else if (timer > waitTime)
            {
                charging = true;
            }
            else
            {
                if (timer == 2)
                {
                    Main.PlaySound(SoundID.Item8, npc.position);
                    for (int i = 0; i < minionRingDustQty; i++)
                    {
                        float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);
                        Dust  dust  = Dust.NewDustPerfect(npc.Center, mod.DustType("AncientGlow"), QwertyMethods.PolarVector(minionRingRadius / 10, theta));
                        dust.noGravity = true;
                    }
                }
                charging = false;
            }
            if (charging)
            {
                npc.velocity = new Vector2((float)Math.Cos(npc.rotation) * chargeSpeed, (float)Math.Sin(npc.rotation) * chargeSpeed);
            }
            else
            {
                npc.Center   = new Vector2(npc.ai[2], npc.ai[3]);
                npc.velocity = new Vector2(0, 0);
                float targetAngle = new Vector2(player.Center.X - npc.Center.X, player.Center.Y - npc.Center.Y).ToRotation();
                npc.rotation = targetAngle;
            }
        }
        public override void PostUpdateMiscEffects()
        {
            if (controlled)
            {
                player.noFallDmg = true;

                player.GetModPlayer <ShapeShifterPlayer>().noDraw = true;

                player.GetModPlayer <ShapeShifterPlayer>().hovercraft = true;
                Mount mount = player.mount;
                player.GetModPlayer <ShapeShifterPlayer>().morphed       = true;
                player.GetModPlayer <ShapeShifterPlayer>().overrideWidth = 40;
                //player.height = 30;
                player.noItems     = true;
                hoverDrift        += (float)Math.PI / 60;
                player.statDefense = 14 + player.GetModPlayer <ShapeShifterPlayer>().morphDef;
                if ((player.controlUp || player.controlJump) && hoverHeight < maxHoverHeight)
                {
                    hoverHeight++;
                }
                else if (player.controlDown && hoverHeight > minHoverHeight)
                {
                    hoverHeight--;
                }
                for (; currentHeight < (maxHoverHeight + 10); currentHeight++)
                {
                    if (!Collision.CanHit(player.Center, 0, 0, player.Center + new Vector2(0, currentHeight), 0, 0))
                    {
                        break;
                    }
                }
                hoverTo = hoverHeight + (float)Math.Sin(hoverDrift) * 16;
                //player.velocity.Y = ( currentHeight-hoverHeight) * .1f;
                if (Math.Abs(currentHeight - hoverTo) > hoverSpeed * 4)
                {
                    if (currentHeight - hoverTo > 0)
                    {
                        player.velocity.Y = hoverSpeed;
                        hoverSpeed        = 6f;
                    }
                    if (currentHeight - hoverTo < 0)
                    {
                        player.velocity.Y = -hoverSpeed;
                        hoverSpeed        = 6f;
                    }
                }
                else
                {
                    player.velocity.Y = (currentHeight - hoverTo) * .1f;
                }

                Vector2 shootFrom = player.Top;
                shootFrom.Y += 8;
                float pointAt = (QwertysRandomContent.LocalCursor[player.whoAmI] - shootFrom).ToRotation();


                player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation = QwertyMethods.SlowRotation(player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation, pointAt, 3);
                //Main.NewText(player.GetModPlayer<ShapeShifterPlayer>(mod).tankCannonRotation);

                if (shotCooldown > 0)
                {
                    shotCooldown--;
                }
                if (player.whoAmI == Main.myPlayer && Main.mouseLeft && !player.HasBuff(mod.BuffType("MorphSickness")) && shotCooldown == 0)
                {
                    shotCooldown = 12;
                    Projectile p = Main.projectile[Projectile.NewProjectile(shootFrom + QwertyMethods.PolarVector(19, player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation), QwertyMethods.PolarVector(12, player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation), ProjectileID.GreenLaser, (int)(HovercraftShift.dmg * player.GetModPlayer <ShapeShifterPlayer>().morphDamage), HovercraftShift.kb, player.whoAmI)];
                    p.magic = false;
                    p.GetGlobalProjectile <MorphProjectile>().morph = true;
                    p.penetrate = 1;
                    p.alpha     = 0;
                    if (Main.netMode == 1)
                    {
                        QwertysRandomContent.UpdateProjectileClass(p);
                    }
                    Main.PlaySound(SoundID.Item12);
                }

                currentHeight = 0; //reset
                hoverTo       = 0;
                hoverSpeed    = 3f;
            }
        }
Esempio n. 9
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D missile = mod.GetTexture("Items/Weapons/MiscSummons/AshMissile");

            for (int i = 0; i < missileCounters.Length; i++)
            {
                spriteBatch.Draw(missile,
                                 projectile.Center + QwertyMethods.PolarVector(2f, projectile.rotation) + QwertyMethods.PolarVector(missileLoadPosition * (float)missileCounters[i] / missileTime * (i == 0 ? 1 : -1), projectile.rotation + (float)Math.PI / 2) - Main.screenPosition,
                                 missile.Frame(), lightColor, projectile.rotation, missile.Size() * .5f, 1f, SpriteEffects.None, 0);
            }

            return(true);
        }
Esempio n. 10
0
        public override bool ExplosionEffect(int explosionSize)
        {
            Main.PlaySound(SoundID.Item62, projectile.position);
            for (int i = 0; i < 2; i++)
            {
                Projectile meteor = Main.projectile[Projectile.NewProjectile(projectile.Center + new Vector2(Main.rand.Next(-20, 20), -1000), QwertyMethods.PolarVector(10, (float)Math.PI / 2 + (float)Math.PI / 16 * Main.rand.NextFloat(-1, 1)), 424 + Main.rand.Next(2), (int)(projectile.damage), projectile.knockBack, projectile.owner, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f)];
                meteor.magic  = false;
                meteor.thrown = true;

                if (Main.netMode == 1)
                {
                    QwertysRandomContent.UpdateProjectileClass(meteor);
                }
            }
            return(true);
        }
        public override void PostUpdateMiscEffects()
        {
            if (controlled)
            {
                player.noKnockback = true;
                //player.Hitbox.Height = 30;
                player.GetModPlayer <ShapeShifterPlayer>().noDraw      = true;
                player.GetModPlayer <ShapeShifterPlayer>().glassCannon = true;
                Mount mount = player.mount;
                player.GetModPlayer <ShapeShifterPlayer>().morphed       = true;
                player.GetModPlayer <ShapeShifterPlayer>().overrideWidth = 30;
                //player.height = 30;
                player.noItems     = true;
                player.statDefense = 0 + player.GetModPlayer <ShapeShifterPlayer>().morphDef;

                Vector2 shootFrom = player.Top;
                //shootFrom.Y -= 4;
                float pointAt = (QwertysRandomContent.LocalCursor[player.whoAmI] - shootFrom).ToRotation();
                if (QwertysRandomContent.LocalCursor[player.whoAmI].Y > player.Top.Y)
                {
                    if (QwertysRandomContent.LocalCursor[player.whoAmI].X > player.Top.X)
                    {
                        pointAt = 0;
                    }
                    else
                    {
                        pointAt = (float)Math.PI;
                    }
                }

                player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation = QwertyMethods.SlowRotation(player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation, pointAt, 3);
                //Main.NewText(player.GetModPlayer<ShapeShifterPlayer>().tankCannonRotation);
                if (player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation > 0)
                {
                    if (player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation > (float)Math.PI / 2)
                    {
                        player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation = (float)Math.PI;
                    }
                    else
                    {
                        player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation = 0;
                    }
                }
                if (shotCooldown > 0)
                {
                    shotCooldown--;
                }
                if (player.whoAmI == Main.myPlayer && Main.mouseLeft && !player.HasBuff(mod.BuffType("MorphSickness")) && shotCooldown == 0)
                {
                    shotCooldown = 21;
                    Projectile.NewProjectile(shootFrom + QwertyMethods.PolarVector(30, player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation), QwertyMethods.PolarVector(16, player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation), mod.ProjectileType("GlassCannonball"), (int)(GlassCannonShift.dmg * player.GetModPlayer <ShapeShifterPlayer>().morphDamage), GlassCannonShift.kb, player.whoAmI);
                }
            }
        }
Esempio n. 12
0
 public override void OnHitByItem(Player player, Item item, int damage, float knockback, bool crit)
 {
     if (Main.netMode == 0)
     {
         npc.width     = 698;
         npc.height    = 698;
         npc.position -= CollisionOffset;
     }
     if (npc.ai[3] == 1)
     {
         float c = 0;
         if (Collision.CheckAABBvLineCollision(player.position, player.Size, BladeStart + QwertyMethods.PolarVector(BladeLength / 2, npc.rotation + (float)Math.PI / 2), BladeStart + QwertyMethods.PolarVector(BladeLength / 2, npc.rotation + (float)Math.PI / 2) + -rotationDirection * QwertyMethods.PolarVector(300, npc.rotation), BladeLength, ref c))
         {
             if (rotationSpeed < (float)Math.PI / 1000f * 35)
             {
                 rotationSpeed += (float)Math.PI / 1000f * 5;
             }
             rotationDirection *= -1;
         }
     }
 }
Esempio n. 13
0
        public override void AI()
        {
            npc.TargetClosest(false);
            Player player = Main.player[npc.target];

            BladeStart = npc.Center + QwertyMethods.PolarVector(HiltLength / 2, npc.rotation + (float)Math.PI / 2);
            BladeTip   = npc.Center + QwertyMethods.PolarVector((HiltLength / 2) + BladeLength, npc.rotation + (float)Math.PI / 2);
            if (!player.active || player.dead)
            {
                npc.TargetClosest(false);
                player = Main.player[npc.target];
                if (!player.active || player.dead)
                {
                    npc.velocity = new Vector2(0f, -40f);
                    if (npc.timeLeft > 10)
                    {
                        npc.timeLeft = 10;
                    }
                    activeCheck = true;
                    return;
                }
            }
            else
            {
                activeCheck = false;
                timer++;
                //Dust.NewDustPerfect(BladeStart + QwertyMethods.PolarVector(BladeLength / 2, npc.rotation + (float)Math.PI / 2), DustID.Fire);
                //npc.rotation = npc.velocity.ToRotation();

                if (npc.ai[3] == 0)
                {
                    if (npc.ai[2] < 6)
                    {
                        if (!rocketMode)
                        {
                            npc.rotation = QwertyMethods.SlowRotation(npc.rotation, npc.velocity.ToRotation(), 4);
                        }
                        if (timer == 1)
                        {
                            finishSwing             = false;
                            toHitSpot2              = false;
                            rocketMode              = false;
                            thrust                  = false;
                            preSwingPlayerDirection = (npc.Center - player.Center).ToRotation();
                            preSwingPlayerDistance  = (player.Center - npc.Center).Length();
                            directionOfAcceleration = preSwingPlayerDirection + (float)Math.PI / 4;
                            hitSpot                 = QwertyMethods.PolarVector(BladeLength, preSwingPlayerDirection) + player.Center;
                            hitSpot2                = QwertyMethods.PolarVector(BladeLength, preSwingPlayerDirection + (float)Math.PI / 2) + player.Center;
                            postSwingSpot           = QwertyMethods.PolarVector(1200, preSwingPlayerDirection + (float)Math.PI / 2) + player.Center;
                            npc.rotation            = preSwingPlayerDirection + (float)Math.PI;
                            //npc.velocity = QwertyMethods.PolarVector(intialBoost, directionOfAcceleration);
                            //npc.velocity -= QwertyMethods.PolarVector(10, directionOfAcceleration + (float)Math.PI / 2);
                        }
                        //Dust.NewDustPerfect(hitSpot, DustID.Fire);
                        //Dust.NewDustPerfect(postSwingSpot, DustID.Fire);
                        //Dust.NewDustPerfect(QwertyMethods.PolarVector(preSwingPlayerDistance, preSwingPlayerDirection) + player.Center, DustID.Fire);

                        if (finishSwing)
                        {
                            npc.velocity = (postSwingSpot - npc.Center) * acceleration;
                            if ((npc.Center - postSwingSpot).Length() < 100 || rocketMode)
                            {
                                if ((npc.Center - player.Center).Length() < 1100)
                                {
                                    rocketMode = true;
                                    float goTo = ((npc.Center - player.Center).ToRotation() + (float)Math.PI / 2);
                                    goTo         = QwertyMethods.PolarVector(1, goTo).ToRotation();
                                    npc.rotation = QwertyMethods.PolarVector(1, npc.rotation).ToRotation();
                                    if (Math.Abs(npc.rotation - goTo) < MathHelper.ToRadians(8) || thrust)
                                    {
                                        thrust       = true;
                                        npc.velocity = QwertyMethods.PolarVector(25, npc.rotation + (float)Math.PI / 2);
                                    }
                                    else
                                    {
                                        npc.rotation = QwertyMethods.SlowRotation(npc.rotation, goTo, 4);
                                        //Main.NewText(MathHelper.ToDegrees(Math.Abs(npc.rotation - ((npc.Center - player.Center).ToRotation() + (float)Math.PI / 2))));
                                        //Main.NewText(npc.rotation + ", " + goTo);
                                    }
                                }
                                else
                                {
                                    finishSwing = false;
                                    timer       = 0;
                                }
                            }
                        }
                        else if (toHitSpot2)
                        {
                            npc.velocity = (hitSpot2 - npc.Center) * acceleration;
                            if ((npc.Center - hitSpot2).Length() < 100)
                            {
                                if (Main.netMode != 1)
                                {
                                    finishSwing   = true;
                                    npc.netUpdate = true;
                                }
                                npc.ai[2]++;
                            }
                        }
                        else
                        {
                            npc.velocity = (hitSpot - npc.Center) * acceleration;
                            if ((npc.Center - hitSpot).Length() < 100)
                            {
                                toHitSpot2 = true;
                            }
                        }
                        if (npc.velocity.Length() > maxSpeed && !thrust)
                        {
                            npc.velocity = npc.velocity.SafeNormalize(-Vector2.UnitY) * maxSpeed;
                        }
                    }
                    else
                    {
                        if (Main.netMode != 1)
                        {
                            npc.ai[2] = 0;
                            npc.ai[3] = Main.rand.Next(attackCount - 1);
                            if (npc.ai[3] >= 0)
                            {
                                npc.ai[3]++;
                            }
                            npc.netUpdate = true;
                        }
                    }
                }
                else if (npc.ai[3] == 1)
                {
                    if (attack2Timer == 0)
                    {
                        preSwingPlayerDirection = (npc.Center - player.Center).ToRotation();
                        rotationSpeed           = ((float)Math.PI / 1000) * 15f;
                    }
                    hitSpot = QwertyMethods.PolarVector(BladeLength / 2, preSwingPlayerDirection) + player.Center;
                    if (attack2Timer < 60)
                    {
                        npc.rotation  = preSwingPlayerDirection - (float)Math.PI / 2;
                        rotationSpeed = ((float)Math.PI / 1000) * 15f;
                    }
                    else
                    {
                        npc.rotation += rotationSpeed * rotationDirection;
                    }
                    if (attack2Timer > 600)
                    {
                        npc.velocity = ((hitSpot + QwertyMethods.PolarVector(1000, -preSwingPlayerDirection)) - npc.Center) * acceleration;
                        if (attack2Timer > 620)
                        {
                            attack2Timer = 0;
                            if (Main.netMode != 1)
                            {
                                npc.ai[3] = Main.rand.Next(attackCount - 1);
                                if (npc.ai[3] >= 1)
                                {
                                    npc.ai[3]++;
                                }
                                npc.netUpdate = true;
                            }
                        }
                    }
                    else
                    {
                        npc.velocity = (hitSpot - npc.Center) * acceleration;
                    }



                    attack2Timer++;
                }
                else if (npc.ai[3] == 2)
                {
                    //Main.NewText(attack3Timer);
                    if (attack3Counter < 8)
                    {
                        if (attack3Timer == 0)
                        {
                            if (Main.netMode != 1)
                            {
                                npc.Center = QwertyMethods.PolarVector(1200, Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI)) + player.Center;
                                preSwingPlayerDirection = (npc.Center - player.Center).ToRotation();
                                npc.rotation            = preSwingPlayerDirection + (float)Math.PI / 2;
                                npc.netUpdate           = true;

                                if (attack3Counter == 2 || attack3Counter == 5)
                                {
                                    Vector2 Spawn = QwertyMethods.PolarVector(300, npc.rotation - (float)Math.PI / 2) + npc.Center;
                                    Spawn.Y += 168;
                                    NPC.NewNPC((int)Spawn.X, (int)Spawn.Y, mod.NPCType("BladeMinion"), ai0: npc.rotation);
                                }
                            }
                        }
                        else
                        {
                            npc.rotation = preSwingPlayerDirection + (float)Math.PI / 2;
                            npc.velocity = QwertyMethods.PolarVector(20, npc.rotation + (float)Math.PI / 2);

                            /*
                             * float goTo = ((npc.Center - player.Center).ToRotation() + (float)Math.PI / 2);
                             * goTo = QwertyMethods.PolarVector(1, goTo).ToRotation();
                             * npc.rotation = QwertyMethods.PolarVector(1, npc.rotation).ToRotation();
                             * Main.NewText(Math.Abs(npc.rotation - goTo) > (float)Math.PI / 2);
                             */
                        }
                        attack3Timer++;
                        if ((npc.Center - player.Center).Length() > 1300)
                        {
                            attack3Timer = 0;
                            attack3Counter++;
                        }
                    }
                    else
                    {
                        if (Main.netMode != 1)
                        {
                            npc.Center = QwertyMethods.PolarVector(1200, Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI)) + player.Center;
                            preSwingPlayerDirection = (npc.Center - player.Center).ToRotation();

                            npc.netUpdate = true;
                        }
                        attack3Counter = 0;
                        if (Main.netMode != 1)
                        {
                            npc.ai[3] = Main.rand.Next(attackCount - 1);
                            if (npc.ai[3] >= 2)
                            {
                                npc.ai[3]++;
                            }
                            npc.netUpdate = true;
                        }
                    }
                }

                /*
                 *  if (Main.netMode == 1)
                 * {
                 *   Main.NewText("client: " + npc.Center);
                 * }
                 *
                 *
                 * if (Main.netMode == 2) // Server
                 * {
                 *   NetMessage.BroadcastChatMessage(Terraria.Localization.NetworkText.FromLiteral("Server: " + npc.Center), Color.Black);
                 * }
                 */
            }
        }
        public override void PreUpdate()
        {
            if (effect && player.GetModPlayer <ShapeShifterPlayer>().morphed)
            {
                bomberDelay--;
                if (bomberDelay <= 0)
                {
                    if (bomberDelay % 30 == 0)
                    {
                        Deck <int> targets = new Deck <int>();
                        for (int n = 0; n < 200; n++)
                        {
                            if (Main.npc[n].active && !Main.npc[n].friendly && !Main.npc[n].dontTakeDamage && !Main.npc[n].immortal && (player.Center - Main.npc[n].Center).Length() < 1000)
                            {
                                targets.Add(n);
                            }
                        }
                        if (targets.Count > 0)
                        {
                            Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/SoundEffects/BombDrop"));
                            float rotation = (float)Math.PI / 2;

                            Projectile.NewProjectile(new Vector2(Main.npc[targets[Main.rand.Next(targets.Count)]].Center.X, player.Center.Y) + QwertyMethods.PolarVector(-500, rotation), QwertyMethods.PolarVector(12, rotation), mod.ProjectileType("MiniBomb"), (int)(140 * player.minionDamage), 0f, player.whoAmI);
                        }
                    }
                    if (bomberDelay < -60)
                    {
                        bomberDelay = 260 + Main.rand.Next(120);
                    }
                }
            }
        }
        // The AI of the projectile

        public override void AI()
        {
            shooter = Main.projectile[(int)projectile.ai[0]];
            Vector2 mousePos = Main.MouseWorld;
            Player  player   = Main.player[projectile.owner];

            if (!shooter.active || shooter.type != mod.ProjectileType("MythrilPrism"))
            {
                projectile.Kill();
            }

            #region Set projectile position

            if (projectile.ai[1] != -1)
            {
                diff = QwertyMethods.PolarVector(2f, (Main.npc[(int)projectile.ai[1]].Center - projectile.Center).ToRotation());
            }
            else
            {
                diff = new Vector2(2f, 0);
            }



            diff.Normalize();
            projectile.velocity  = diff;
            projectile.direction = projectile.Center.X > shooter.Center.X ? 1 : -1;
            projectile.netUpdate = true;

            projectile.position = new Vector2(shooter.Center.X, shooter.Center.Y) + projectile.velocity * MoveDistance;
            projectile.timeLeft = 2;
            int dir = projectile.direction;

            /*
             * player.ChangeDir(dir);
             * player.heldProj = projectile.whoAmI;
             * player.itemTime = 2;
             * player.itemAnimation = 2;
             * player.itemRotation = (float)Math.Atan2(projectile.velocity.Y * dir, projectile.velocity.X * dir);
             */
            #endregion

            #region Charging process
            // Kill the projectile if the player stops channeling



            Vector2 offset = projectile.velocity;
            offset *= MoveDistance - 20;
            Vector2 pos = new Vector2(shooter.Center.X, shooter.Center.Y) + offset - new Vector2(10, 10);

            if (Charge < MaxChargeValue)
            {
                Charge++;
            }

            int chargeFact = (int)(Charge / 20f);



            #endregion


            if (Charge < MaxChargeValue)
            {
                return;
            }
            Vector2 start = new Vector2(shooter.Center.X, shooter.Center.Y);
            Vector2 unit  = projectile.velocity;
            unit *= -1;

            for (Distance = MoveDistance; Distance <= 50f; Distance += 1f)
            {
                start = new Vector2(shooter.Center.X, shooter.Center.Y) + projectile.velocity * Distance;

                /*
                 * if (!Collision.CanHit(new Vector2(shooter.Center.X, shooter.Center.Y), 1, 1, start, 1, 1))
                 * {
                 *  Distance -= 5f;
                 *  break;
                 * }
                 */
            }



            //Add lights
            DelegateMethods.v3_1 = new Vector3(0.8f, 0.8f, 1f);
            Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * (Distance - MoveDistance), 26,
                               DelegateMethods.CastLight);
        }
Esempio n. 16
0
        public override void AI()
        {
            Main.player[projectile.owner].UpdateMaxTurrets();
            Player player = Main.player[projectile.owner];

            for (int i = 0; i < missileCounters.Length; i++)
            {
                if (missileCounters[i] < missileTime)
                {
                    missileCounters[i]++;
                    break;
                }
            }
            if (QwertyMethods.ClosestNPC(ref target, 1000, projectile.Center, false, player.MinionAttackTargetNPC))
            {
                for (int i = 0; i < missileCounters.Length; i++)
                {
                    projectile.rotation = (target.Center - projectile.Center).ToRotation();
                    if (missileCounters[i] == missileTime)
                    {
                        //shoot
                        missileCounters[i] = 0;
                        Projectile.NewProjectile(projectile.Center + QwertyMethods.PolarVector(2f, projectile.rotation) + QwertyMethods.PolarVector(missileLoadPosition * (i == 0 ? 1 : -1), projectile.rotation + (float)Math.PI / 2),
                                                 QwertyMethods.PolarVector(2f, projectile.rotation), mod.ProjectileType("AshMissile"), projectile.damage, projectile.knockBack, projectile.owner);
                    }
                }
            }
        }
        public override void AI()
        {
            npc.GetGlobalNPC <FortressNPCGeneral>().fortressNPC = true;
            Lighting.AddLight(npc.Center, new Vector3(1.2f, 1.2f, 1.2f));
            if (npc.life > npc.lifeMax)
            {
                npc.life = npc.lifeMax;
            }
            if (Main.expertMode)
            {
                damage = 7;
            }
            else
            {
                damage = 9;
            }

            if (start)
            {
                if (QwertyWorld.hasSummonedFortressBoss)
                {
                    startFight = true;
                }
                start = false;
                for (int i = 0; i < previousHealth.Length; i++)
                {
                    previousHealth[i] = npc.lifeMax;
                }
            }
            dpsCheckCounter++;
            if (dpsCheckCounter % 60 == 0)
            {
                for (int i = previousHealth.Length - 1; i > 0; i--)
                {
                    previousHealth[i] = previousHealth[i - 1];
                }
                previousHealth[0] = npc.life;

                dps = (((float)previousHealth[previousHealth.Length - 1] - (float)previousHealth[0]) / (float)previousHealth.Length);

                //Main.NewText("dps: " + dps);
            }
            if (Main.dungeonX < Main.maxTilesX * .5f)
            {
                Center = (int)((double)Main.maxTilesX * 0.8) * 16;
            }
            else
            {
                Center = (int)((double)Main.maxTilesX * 0.2) * 16;
            }
            player = Main.player[npc.target];
            npc.TargetClosest(true);
            if (!player.active || player.dead)
            {
                quitCount++;
                if (quitCount >= 30)
                {
                    npc.position.Y += 100000f;
                    playerDied      = true;
                }
            }
            else
            {
                quitCount = 0;
            }
            directionOfPlayer = (player.Center - npc.Center).ToRotation();
            if (Main.maxTilesX > 8000)
            {
                lowerLimit            = 280 * 16;
                maxDistanceFromCenter = 750 * 16;
            }
            else if (Main.maxTilesX > 6000)
            {
                lowerLimit            = 230 * 16;
                maxDistanceFromCenter = 550 * 16;
            }
            else
            {
                lowerLimit            = 130 * 16;
                maxDistanceFromCenter = 320 * 16;
            }
            if (npc.Center.Y < upperLimit)
            {
                YDirection = 1;
            }
            if (npc.Center.Y > lowerLimit)
            {
                YDirection = -1;
            }
            float Xdistance = Math.Abs(player.Center.X - npc.Center.X);

            if (Xdistance > 1400)
            {
                speedX = 0;
                impatient++;
                if (impatient == 240 && !playerDied)
                {
                    string key          = "Mods.QwertysRandomContent.DivineMock";
                    Color  messageColor = Color.Orange;
                    if (Main.netMode == 2) // Server
                    {
                        NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor);
                    }
                    else if (Main.netMode == 0) // Single Player
                    {
                        Main.NewText(Language.GetTextValue(key), messageColor);
                    }
                }
                if (impatient > 240 && npc.life < npc.lifeMax)
                {
                    npc.life++;
                }
            }
            else if (Xdistance > 400)
            {
                speedX    = 2;
                impatient = 0;
            }
            else
            {
                speedX    = (400f - Xdistance) / 80f + 2;
                impatient = 0;
            }
            if (startFight)
            {
                if (runOnce)
                {
                    runOnce = false;
                }
                attackTimer++;
                if (attackTimer > attackDelay)
                {
                    Main.PlaySound(SoundID.Item43, npc.Center);
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    if (pickAttack)
                    {
                        if (Main.netMode != 1)
                        {
                            npc.ai[0]     = Main.rand.Next(6);
                            npc.netUpdate = true;
                        }
                        pickAttack = false;
                    }
                    if (npc.ai[0] == 4 && (NPC.AnyNPCs(mod.NPCType("HealingBarrier")) || (int)(dps / 12f) < 2))
                    {
                        npc.ai[0]     = 0;
                        npc.netUpdate = true;
                    }
                    if (npc.ai[0] == 5)
                    {
                        int numberOfProjectiles = 5;
                        if (Main.expertMode)
                        {
                            numberOfProjectiles += 4;
                        }
                        float spread = 2 * (float)Math.PI;


                        for (int p = 0; p < numberOfProjectiles; p++)
                        {
                            float shiftedAim = (directionOfPlayer - (spread / 2)) + (spread * ((float)p / (float)numberOfProjectiles));
                            float speed      = 1;
                            Projectile.NewProjectile(npc.Center + QwertyMethods.PolarVector(speed, shiftedAim), QwertyMethods.PolarVector(speed, shiftedAim), mod.ProjectileType("CaeliteSaw"), damage, 0, player.whoAmI, npc.whoAmI);
                        }
                        attackTimer = 0;
                    }
                    else if (npc.ai[0] == 4)
                    {
                        int numberOfProjectiles = (int)(dps / 12f);

                        for (int i = 0; i < numberOfProjectiles; i++)
                        {
                            NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("HealingBarrier"), 0, (float)i / (float)numberOfProjectiles * 2 * (float)Math.PI, npc.whoAmI * -npc.direction);
                        }
                        attackTimer = 0;
                    }
                    else if (npc.ai[0] == 3)
                    {
                        int   numberOfProjectiles = 7;
                        float spread = (float)Math.PI / 2;


                        for (int p = 0; p < numberOfProjectiles; p++)
                        {
                            float shiftedAim = (directionOfPlayer - (spread / 2)) + Main.rand.NextFloat(spread);
                            float speed      = Main.rand.Next(7, 10);
                            Projectile.NewProjectile(npc.Center, QwertyMethods.PolarVector(speed, shiftedAim), mod.ProjectileType("Deflect"), (int)(damage * 1.2f), 0, player.whoAmI, npc.whoAmI);
                        }
                        attackTimer = 0;
                    }
                    else
                    {
                        int   numberOfProjectiles = 3;
                        float spread = (float)Math.PI / 8;


                        for (int p = 0; p < numberOfProjectiles; p++)
                        {
                            float shiftedAim = (directionOfPlayer - (spread / 2)) + (spread * ((float)p / (float)numberOfProjectiles));
                            float speed      = 5;
                            Projectile.NewProjectile(npc.Center, QwertyMethods.PolarVector(speed, shiftedAim), mod.ProjectileType("BarrierSpread"), damage, 0, player.whoAmI, npc.whoAmI);
                        }
                        attackTimer = 0;
                    }
                }
                else
                {
                    pickAttack = true;
                }
                if (npc.Center.X < player.Center.X && npc.Center.X < Center - maxDistanceFromCenter && Main.netMode != 1)
                {
                    npc.Center    = new Vector2(player.Center.X + Xdistance, npc.Center.Y);
                    npc.netUpdate = true;
                }
                if (npc.Center.X > player.Center.X && npc.Center.X > Center + maxDistanceFromCenter && Main.netMode != 1)
                {
                    npc.Center    = new Vector2(player.Center.X - Xdistance, npc.Center.Y);
                    npc.netUpdate = true;
                }
                npc.spriteDirection = npc.direction;
                XDirection          = -npc.direction;
                npc.velocity        = new Vector2(speedX * XDirection, speedY * YDirection);
                //Main.NewText(Xdistance);
                //Main.NewText(player.GetModPlayer<FortressBiome>().TheFortress);
            }
            else
            {
                //Main.NewText(player.GetModPlayer<FortressBiome>().TheFortress);
                QwertyWorld.hasSummonedFortressBoss = true;
                if (Main.netMode != 2)
                {
                    aggressionTimer++;
                    if (aggressionTimer > 20 * 60)
                    {
                        string key          = "Mods.QwertysRandomContent.DivineStart";
                        Color  messageColor = Color.Orange;
                        if (Main.netMode == 2) // Server
                        {
                            NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor);
                        }
                        else if (Main.netMode == 0) // Single Player
                        {
                            Main.NewText(Language.GetTextValue(key), messageColor);
                        }
                        startFight    = true;
                        npc.netUpdate = true;
                    }
                    else if (!player.GetModPlayer <FortressBiome>().TheFortress&& aggressionTimer > 10)
                    {
                        string key          = "Mods.QwertysRandomContent.DivineLeave";
                        Color  messageColor = Color.Orange;
                        if (Main.netMode == 2) // Server
                        {
                            NetMessage.BroadcastChatMessage(NetworkText.FromKey(key), messageColor);
                        }
                        else if (Main.netMode == 0) // Single Player
                        {
                            Main.NewText(Language.GetTextValue(key), messageColor);
                        }
                        npc.active = false;
                    }
                }
            }
        }
Esempio n. 18
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            player.UpdateMaxTurrets();


            if (QwertyMethods.ClosestNPC(ref target, maxDistance, projectile.Center, false, player.MinionAttackTargetNPC))
            {
                timer++;
                projectile.rotation = (target.Center - projectile.Center).ToRotation();
                if (timer % reloadTime == 0)
                {
                    if (timer % (reloadTime * 2) == 0)
                    {
                        projectile.frame = 1;
                        si = 1;
                    }
                    else
                    {
                        projectile.frame = 2;
                        si = -1;
                    }

                    Vector2 shootFrom = projectile.Center + QwertyMethods.PolarVector(12, projectile.rotation) + QwertyMethods.PolarVector(si * 4, projectile.rotation + (float)Math.PI / 2);
                    //if (Main.netMode != 1)
                    {
                        Projectile.NewProjectile(shootFrom, QwertyMethods.PolarVector(1, projectile.rotation), mod.ProjectileType("RiptideStream"), projectile.damage, projectile.knockBack, projectile.owner);
                    }
                }
            }
            else
            {
                timer            = 0;
                projectile.frame = 0;
            }
        }
Esempio n. 19
0
        public override void HitEffect(int hitDirection, double damage)
        {
            if (npc.life <= 0)
            {
                Vector2 pos  = npc.Center + QwertyMethods.PolarVector(-16, npc.rotation + (float)Math.PI / 2);
                Gore    gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/MiniDebris_1"), 1f)];
                gore.rotation = npc.rotation;

                pos           = npc.Center + QwertyMethods.PolarVector(14, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/MiniDebris_2"), 1f)];
                gore.rotation = npc.rotation;
                for (int i = 0; i < 180; i++)
                {
                    float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);
                    Dust  dust  = Dust.NewDustPerfect(npc.Center, mod.DustType("AncientGlow"), QwertyMethods.PolarVector(Main.rand.Next(1, 9), theta));
                    dust.noGravity = true;
                }
            }
            for (int i = 0; i < 10; i++)
            {
                int  dustType  = 148;
                int  dustIndex = Dust.NewDust(npc.position, npc.width, npc.height, dustType);
                Dust dust      = Main.dust[dustIndex];
                dust.velocity.X = dust.velocity.X + Main.rand.Next(-50, 51) * 0.01f;
                dust.velocity.Y = dust.velocity.Y + Main.rand.Next(-50, 51) * 0.01f;
                dust.scale     *= 1f + Main.rand.Next(-30, 31) * 0.01f;
            }
        }
Esempio n. 20
0
        public override void AI()
        {
            npc.GetGlobalNPC <FortressNPCGeneral>().fortressNPC = true;
            if (npc.ai[0] == 0f)
            {
                npc.TargetClosest(true);
                npc.direction = 1;
                Player initPlayer = Main.player[npc.target];
                if (initPlayer.Center.X < npc.Center.X)
                {
                    //startDirection = 1;
                }
                npc.noGravity  = true;
                npc.directionY = 1;
                npc.ai[0]      = 1f;
                Point origin = npc.Center.ToTileCoordinates();
                Point point;

                while (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(1), new GenCondition[]
                {
                    new Conditions.IsSolid()
                }), out point))
                {
                    npc.position.Y++;
                    origin = npc.Center.ToTileCoordinates();
                }
            }
            shootFrom = npc.Center + QwertyMethods.PolarVector(gunShift, npc.rotation) * -startDirection + QwertyMethods.PolarVector(gunShiftUp, npc.rotation - (float)Math.PI / 2);
            int speed = 2;

            if (npc.ai[1] == 0f)
            {
                //npc.rotation += (float)(npc.direction * npc.directionY) * 0.13f;
                if (npc.collideY)
                {
                    npc.ai[0] = 2f;
                }
                if (!npc.collideY && npc.ai[0] == 2f)
                {
                    npc.direction = -npc.direction;
                    npc.ai[1]     = 1f;
                    npc.ai[0]     = 1f;
                }
                if (npc.collideX)
                {
                    npc.directionY = -npc.directionY;
                    npc.ai[1]      = 1f;
                }
            }
            else
            {
                //npc.rotation -= (float)(npc.direction * npc.directionY) * 0.13f;
                if (npc.collideX)
                {
                    npc.ai[0] = 2f;
                }
                if (!npc.collideX && npc.ai[0] == 2f)
                {
                    npc.directionY = -npc.directionY;
                    npc.ai[1]      = 0f;
                    npc.ai[0]      = 1f;
                }
                if (npc.collideY)
                {
                    npc.direction = -npc.direction;
                    npc.ai[1]     = 0f;
                }
            }
            //npc.TargetClosest(true);
            Player player = Main.player[npc.target];

            if (Collision.CanHit(shootFrom, 0, 0, player.Center, 0, 0) && (player.Center - npc.Center).Length() < 1000)
            {
                npc.velocity.X = 0;
                npc.velocity.Y = 0;
                aimDirection   = (player.Center - npc.Center).ToRotation();
                timer++;
                if (timer > 180)
                {
                    float shootSpeed = 24;

                    Projectile.NewProjectile(shootFrom.X, shootFrom.Y, (float)Math.Cos(aimDirection) * shootSpeed, (float)Math.Sin(aimDirection) * shootSpeed, mod.ProjectileType("MollusketSnipe"), 15, 0, player.whoAmI);
                    timer = 0;
                }
                if (timer > 60)
                {
                    alternateColor = true;
                }
                else
                {
                    alternateColor = false;
                }
                if (timer > 30)
                {
                    drawLine = true;
                }
                else
                {
                    drawLine = false;
                }
            }
            else
            {
                drawLine       = false;
                alternateColor = false;
                timer          = 0;
                npc.velocity.X = (float)(speed * npc.direction);
                npc.velocity.Y = (float)(speed * npc.directionY);
                npc.rotation   = npc.velocity.ToRotation();
                npc.rotation  += (float)Math.PI / 4 * startDirection;
                aimDirection   = npc.rotation;

                /*
                 * if(npc.velocity.X >0 && npc.velocity.Y >0)
                 * {
                 *  npc.rotation = 0;
                 * }
                 * else if(npc.velocity.X < 0 && npc.velocity.Y > 0)
                 * {
                 *  npc.rotation = (float)Math.PI;
                 * }
                 * else if (npc.velocity.X > 0 && npc.velocity.Y < 0)
                 * {
                 *  npc.rotation = (float)Math.PI;
                 * }
                 * else if (npc.velocity.X < 0 && npc.velocity.Y < 0)
                 * {
                 *  npc.rotation = (float)Math.PI;
                 * }
                 */
                //npc.spriteDirection = npc.direction;
            }

            float num281 = (float)(270 - (int)Main.mouseTextColor) / 400f;

            npc.oldVelocity = npc.velocity;
            npc.collideX    = false;
            npc.collideY    = false;
            Vector2 position = npc.Center;
            int     num      = 12;
            int     num2     = 12;

            position.X  -= (float)(num / 2);
            position.Y  -= (float)(num2 / 2);
            npc.velocity = Collision.noSlopeCollision(position, npc.velocity, num, num2, true, true);
            if (npc.oldVelocity.X != npc.velocity.X)
            {
                npc.collideX = true;
            }
            if (npc.oldVelocity.Y != npc.velocity.Y)
            {
                npc.collideY = true;
            }
            //Lighting.AddLight((int)(npc.position.X + (float)(npc.width / 2)) / 16, (int)(npc.position.Y + (float)(npc.height / 2)) / 16, 0.9f, 0.3f + num281, 0.2f);
            return;
        }
Esempio n. 21
0
        public override void AI()
        {
            if (runOnce)
            {
                projectile.rotation = projectile.velocity.ToRotation();

                runOnce = false;
            }
            Player player = Main.player[projectile.owner];

            shotCounter++;
            if (player.HeldItem.GetGlobalItem <ChromeGunToggle>().mode == 3)
            {
                projectile.timeLeft = 300;
            }
            else if (player.HeldItem.type != mod.ItemType("ChromeShotgunDefault"))
            {
                projectile.Kill();
            }
            Vector2 spot = player.Center;

            if (QwertyMethods.ClosestNPC(ref target, 1000, projectile.Center, false, player.MinionAttackTargetNPC))
            {
                spot = target.Center;
            }
            Vector2 Difference = (spot - projectile.Center);

            projectile.rotation = QwertyMethods.SlowRotation(projectile.rotation, Difference.ToRotation(), 5);
            if (Difference.Length() > 100)
            {
                projectile.velocity = Difference *= .02f;
            }
            else
            {
                projectile.velocity = Vector2.Zero;
            }
            for (int i = 0; i < 2; i++)
            {
                NPC gunTarget = new NPC();
                if (QwertyMethods.ClosestNPC(ref gunTarget, 450, GunPositions[i], false, player.MinionAttackTargetNPC))
                {
                    GunRotations[i] = QwertyMethods.SlowRotation(GunRotations[i], (gunTarget.Center - GunPositions[i]).ToRotation() + (float)Math.PI / 2 * (i == 1 ? 1 : -1) - projectile.rotation, 6);
                    if (shotCounter % 30 == i * 15)
                    {
                        int   bullet       = ProjectileID.Bullet;
                        bool  canShoot     = true;
                        float speedB       = 14f;
                        int   weaponDamage = projectile.damage;
                        float kb           = projectile.knockBack;
                        player.PickAmmo(QwertyMethods.MakeItemFromID(mod.ItemType("ChromeShotgunDefault")), ref bullet, ref speedB, ref canShoot, ref weaponDamage, ref kb, false);
                        if (canShoot)
                        {
                            Projectile.NewProjectile(GunPositions[i], QwertyMethods.PolarVector(16, GunRotations[i] + projectile.rotation + (float)Math.PI / 2 * (i == 0 ? 1 : -1)), bullet, weaponDamage, kb, projectile.owner);
                        }
                    }
                }
                else
                {
                    GunRotations[i] = QwertyMethods.SlowRotation(GunRotations[i], 0f, 6);
                }
            }
            GunPositions[0] = projectile.Center + QwertyMethods.PolarVector(13, projectile.rotation) + QwertyMethods.PolarVector(14, projectile.rotation + (float)Math.PI / 2);
            GunPositions[1] = projectile.Center + QwertyMethods.PolarVector(13, projectile.rotation) + QwertyMethods.PolarVector(14, projectile.rotation - (float)Math.PI / 2);
        }
        public override void AI()
        {
            //projectile.timeLeft = 2;

            Player player = Main.player[projectile.owner];

            player.Center        = projectile.Center;
            player.immune        = true;
            player.immuneTime    = 2;
            player.statDefense   = 0;
            player.itemAnimation = 2;
            player.itemTime      = 2;
            player.GetModPlayer <ShapeShifterPlayer>().noDraw = true;
            player.AddBuff(mod.BuffType("HealingHalt"), 10);
            player.AddBuff(mod.BuffType("MorphCooldown"), (int)((18 * player.HeldItem.GetGlobalItem <ShapeShifterItem>().PrefixorphCooldownModifier *player.GetModPlayer <ShapeShifterPlayer>().coolDownDuration) * 60f));
            //projectile.timeLeft = 2;
            //player.mount = null;
            //player.noItems = true;
            //player.buffTime[mod.BuffType("MorphCooldown")]++;
            if (player.controlLeft)
            {
                projectile.rotation -= (float)Math.PI / 60;
            }
            if (player.controlRight)
            {
                projectile.rotation += (float)Math.PI / 60;
            }
            projectile.velocity = QwertyMethods.PolarVector(10, projectile.rotation - (float)Math.PI / 2);
            dustYoffset         = 20;
            for (int i = 0; i < 2; i++)
            {
                Dust dust = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(dustYoffset, projectile.rotation + (float)Math.PI / 2) + QwertyMethods.PolarVector(Main.rand.Next(-9, 9), projectile.rotation), mod.DustType("AncientGlow"));
            }
        }
Esempio n. 23
0
        public override void AI()
        {
            Player       player    = Main.player[projectile.owner];
            QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>();

            if (modPlayer.ShieldMinion)
            {
                projectile.timeLeft = 2;
            }
            for (int p = 0; p < 1000; p++)
            {
                if (Main.projectile[p].type == mod.ProjectileType("ShieldMinion") && Main.projectile[p].active && Main.projectile[p].owner == projectile.owner && Main.projectile[p].ai[1] == projectile.ai[1])
                {
                    ShieldCount++;
                }
            }

            for (int p = 0; p < 1000; p++)
            {
                if (Main.projectile[p].type == mod.ProjectileType("ShieldMinion") && Main.projectile[p].active && Main.projectile[p].owner == projectile.owner && Main.projectile[p].ai[1] == projectile.ai[1])
                {
                    if (p == projectile.whoAmI)
                    {
                        break;
                    }
                    else
                    {
                        identity++;
                    }
                }
            }
            projectile.friendly = (projectile.ai[1] == charging);
            if (projectile.ai[1] != charging)
            {
                if (player.velocity.Length() > .1f)
                {
                    LatestValidVelocity = player.velocity;
                }

                float myOffset = (((float)Math.PI / 2) * (float)(identity + 1)) / (ShieldCount + 1) - (float)Math.PI / 4;
                flyTo = player.Center + QwertyMethods.PolarVector(projectile.ai[1] == guarding ? 120 : -50, (QwertysRandomContent.LocalCursor[projectile.owner] - player.Center).ToRotation() + myOffset);

                if (flyTo != null && flyTo != Vector2.Zero)
                {
                    projectile.velocity = (flyTo - projectile.Center) * .1f;
                }
            }
            switch ((int)projectile.ai[1])
            {
            case guarding:
                projectile.frame = 0;
                foreach (Projectile OtherProjectile in Main.projectile)
                {
                    if (OtherProjectile.hostile && OtherProjectile.active && OtherProjectile.velocity != Vector2.Zero && OtherProjectile.damage > 0 && Collision.CheckAABBvAABBCollision(projectile.position, projectile.Size, OtherProjectile.position, OtherProjectile.Size))
                    {
                        if (OtherProjectile.damage * 2 * (Main.expertMode ? 2 : 1) < projectile.damage)
                        {
                            OtherProjectile.Kill();
                        }
                        projectile.ai[1] = cooling;
                        chargeTimer      = -300;
                        break;
                    }
                }
                if (QwertyMethods.ClosestNPC(ref target, 1000, player.Center, true, player.MinionAttackTargetNPC))
                {
                    eyeOffset    = (target.Center - projectile.Center).SafeNormalize(-Vector2.UnitY);
                    eyeOffset.X *= horizontalEyeMultiploer;
                    eyeOffset.Y *= verticalEyeMultiplier;
                    if ((target.Center - projectile.Center).Length() < 120)
                    {
                        projectile.velocity = QwertyMethods.PolarVector(24, (target.Center - projectile.Center).ToRotation());
                        projectile.ai[1]    = charging;
                        chargeTimer         = 10;
                        break;
                    }
                }
                else
                {
                    eyeOffset = Vector2.Zero;
                }

                break;

            case charging:
                projectile.frame = 0;
                chargeTimer--;
                if (chargeTimer <= 0)
                {
                    projectile.ai[1] = cooling;
                    chargeTimer      = -300;
                }
                break;

            case cooling:
                projectile.frame = 1;
                chargeTimer++;
                if (chargeTimer >= 0)
                {
                    projectile.ai[1] = guarding;
                }
                break;
            }


            identity    = 0;
            ShieldCount = 0;
        }
        public override void AI()
        {
            Player player = Main.player[projectile.owner];



            Main.PlaySound(SoundID.Item62, projectile.position);


            for (int i = 0; i < 1600; i++)
            {
                float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);
                Dust  dust  = Dust.NewDustPerfect(projectile.Center, mod.DustType("AncientGlow"), QwertyMethods.PolarVector(Main.rand.Next(2, 120), theta));
                dust.noGravity = true;
            }
        }
Esempio n. 25
0
        public override void AI()
        {
            noDust = false;
            // Since we access the owner player instance so much, it's useful to create a helper local variable for this
            // Sadly, Projectile/ModProjectile does not have its own
            Player projOwner = Main.player[projectile.owner];
            // Here we set some of the projectile's owner properties, such as held item and itemtime, along with projectile direction and position based on the player
            Vector2 ownerMountedCenter = projOwner.RotatedRelativePoint(projOwner.MountedCenter, true);

            vel = maxDistance / projOwner.itemAnimationMax / 2;
            projectile.velocity   = new Vector2((float)Math.Cos(projectile.velocity.ToRotation()) * vel, (float)Math.Sin(projectile.velocity.ToRotation()) * vel);
            projectile.direction  = projOwner.direction;
            projOwner.heldProj    = projectile.whoAmI;
            projOwner.itemTime    = projOwner.itemAnimation;
            projectile.position.X = ownerMountedCenter.X - (float)(projectile.width / 2);
            projectile.position.Y = ownerMountedCenter.Y - (float)(projectile.height / 2);

            // As long as the player isn't frozen, the spear can move
            if (!projOwner.frozen)
            {
                if (movementFactor == 0f)                                     // When initially thrown out, the ai0 will be 0f
                {
                    movementFactor       = 0;                                 // Make sure the spear moves forward when initially thrown out
                    projectile.netUpdate = true;                              // Make sure to netUpdate this spear
                }
                if (projOwner.itemAnimation < projOwner.itemAnimationMax / 2) // Somewhere along the item animation, make sure the spear moves back
                {
                    if (projOwner.channel)
                    {
                        projectile.friendly = false;
                        projOwner.itemAnimation++;
                        if (Collision.CanHit(projOwner.Center, 0, 0, projectile.Center, 0, 0))
                        {
                            noDust = true;
                            streamCounter++;
                            if (streamCounter % (int)(16f * projOwner.meleeSpeed) == 0)
                            {
                                //if (Main.netMode != 1)
                                {
                                    Projectile.NewProjectile(projectile.Center + QwertyMethods.PolarVector(180, projectile.rotation - (3 * (float)Math.PI / 4)) + QwertyMethods.PolarVector(5, projectile.rotation - (1 * (float)Math.PI / 4)), QwertyMethods.PolarVector(1, projectile.rotation - (3 * (float)Math.PI / 4)), mod.ProjectileType("HydrospearStream"), projectile.damage, projectile.knockBack, projectile.owner);
                                }
                            }
                        }
                    }
                    else
                    {
                        projectile.friendly = true;
                        movementFactor     -= movefactSpeed;
                    }

                    //Main.NewText("Hi");
                }
                else // Otherwise, increase the movement factor
                {
                    projectile.friendly = true;
                    movementFactor     += movefactSpeed;
                }
            }
            // Change the spear position based off of the velocity and the movementFactor
            projectile.position += projectile.velocity * movementFactor;
            // When we reach the end of the animation, we can kill the spear projectile
            if (projOwner.itemAnimation == 0)
            {
                projectile.Kill();
            }
            // Apply proper rotation, with an offset of 135 degrees due to the sprite's rotation, notice the usage of MathHelper, use this class!
            // MathHelper.ToRadians(xx degrees here)
            projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(135f);
            // Offset by 90 degrees here
            if (projectile.spriteDirection == -1)
            {
                projectile.rotation -= MathHelper.ToRadians(90f);
            }
            if (!noDust)
            {
                Dust k = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(-4, projectile.rotation - (3 * (float)Math.PI / 4)) + QwertyMethods.PolarVector(4, projectile.rotation - (1 * (float)Math.PI / 4)), 172);
                k.velocity = Vector2.Zero;
            }
        }
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            int   bulletCount = 5 + Main.rand.Next(2);
            float dir         = new Vector2(speedX, speedY).ToRotation();
            float speed       = new Vector2(speedX, speedY).Length();

            for (int b = 0; b < bulletCount; b++)
            {
                Projectile p = Main.projectile[Projectile.NewProjectile(position + QwertyMethods.PolarVector(24, dir), QwertyMethods.PolarVector(speed, dir + Main.rand.NextFloat(-1, 1) * (float)Math.PI / 18), type, damage, knockBack, player.whoAmI)];
                p.extraUpdates++;
                p.GetGlobalProjectile <Etims>().effect = true;
            }

            player.velocity = QwertyMethods.PolarVector(12f, dir + (float)Math.PI);


            return(false);
        }
Esempio n. 27
0
        public override void AI()
        {
            Player       player    = Main.player[projectile.owner];
            QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>();

            if (modPlayer.AncientMinion)
            {
                projectile.timeLeft = 2;
            }


            if (runOnce)
            {
                //Main.PlaySound(SoundID.Item8);

                if (Main.netMode != 2)
                {
                    moveTo.X             = projectile.Center.X;
                    moveTo.Y             = projectile.Center.Y;
                    projectile.netUpdate = true;
                }
                runOnce = false;
            }

            if (QwertyMethods.ClosestNPC(ref target, maxDistance, player.Center, true, player.MinionAttackTargetNPC))
            {
                timer++;
                if (timer > waitTime + chargeTime)
                {
                    for (int k = 0; k < 200; k++)
                    {
                        projectile.localNPCImmunity[k] = 0;
                    }
                    for (int i = 0; i < minionRingDustQty; i++)
                    {
                        float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);

                        Dust dust = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(minionRingRadius, theta), mod.DustType("AncientGlow"), QwertyMethods.PolarVector(-minionRingRadius / 10, theta));
                        dust.noGravity = true;
                    }
                    if (Main.netMode != 2)
                    {
                        projectile.ai[1]     = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);
                        projectile.netUpdate = true;
                    }
                    moveTo = new Vector2(target.Center.X + (float)Math.Cos(projectile.ai[1]) * 180, target.Center.Y + (float)Math.Sin(projectile.ai[1]) * 180);
                    if (Main.netMode != 2)
                    {
                        projectile.netUpdate = true;
                    }
                    justTeleported = true;
                    timer          = 0;
                    noTargetTimer  = 0;
                }
                else if (timer > waitTime)
                {
                    charging = true;
                }
                else
                {
                    if (timer == 2)
                    {
                        Main.PlaySound(SoundID.Item8, projectile.Center);
                        for (int i = 0; i < minionRingDustQty; i++)
                        {
                            float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);
                            Dust  dust  = Dust.NewDustPerfect(projectile.Center, mod.DustType("AncientGlow"), QwertyMethods.PolarVector(minionRingRadius / 10, theta));
                            dust.noGravity = true;
                        }
                    }
                    charging = false;
                }
                if (charging)
                {
                    projectile.velocity = new Vector2((float)Math.Cos(projectile.rotation) * chargeSpeed, (float)Math.Sin(projectile.rotation) * chargeSpeed);
                }
                else
                {
                    projectile.Center   = new Vector2(moveTo.X, moveTo.Y);
                    projectile.velocity = new Vector2(0, 0);
                    float targetAngle = new Vector2(target.Center.X - projectile.Center.X, target.Center.Y - projectile.Center.Y).ToRotation();
                    projectile.rotation = targetAngle;
                }
            }
            else
            {
                noTargetTimer++;
                if (noTargetTimer == 2)
                {
                    Main.PlaySound(SoundID.Item8);
                    for (int i = 0; i < minionRingDustQty; i++)
                    {
                        float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);
                        Dust  dust  = Dust.NewDustPerfect(projectile.Center, mod.DustType("AncientGlow"), QwertyMethods.PolarVector(minionRingRadius / 10, theta));
                        dust.noGravity = true;
                    }
                }
                if ((projectile.Center - player.Center).Length() > 300)
                {
                    if (Main.netMode != 2)
                    {
                        projectile.ai[1]     = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);
                        projectile.netUpdate = true;
                    }
                    for (int i = 0; i < minionRingDustQty; i++)
                    {
                        float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI);

                        Dust dust = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(minionRingRadius, theta), mod.DustType("AncientGlow"), QwertyMethods.PolarVector(-minionRingRadius / 10, theta));
                        dust.noGravity = true;
                    }
                    noTargetTimer  = 0;
                    moveTo         = new Vector2(player.Center.X + (float)Math.Cos(projectile.ai[1]) * 100, player.Center.Y + (float)Math.Sin(projectile.ai[1]) * 100);
                    justTeleported = true;
                }

                projectile.Center = moveTo;

                float targetAngle = new Vector2(player.Center.X - projectile.Center.X, player.Center.Y - projectile.Center.Y).ToRotation();
                projectile.rotation = targetAngle;
            }
            if (justTeleported)
            {
                justTeleported = false;
            }

            projectile.frameCounter++;
        }
        public override void AI()
        {
            Player player = Main.player[projectile.owner];
            //Main.NewText(moveTo);
            QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(mod);

            prismCount = player.ownedProjectileCounts[mod.ProjectileType("MythrilPrism")];
            if (modPlayer.mythrilPrism)
            {
                projectile.timeLeft = 2;
            }
            for (int p = 0; p < 1000; p++)
            {
                if (Main.projectile[p].type == mod.ProjectileType("MythrilPrism"))
                {
                    if (p == projectile.whoAmI)
                    {
                        break;
                    }
                    else
                    {
                        identity++;
                    }
                }
            }
            if (player.MinionAttackTargetNPC != -1)
            {
                for (int k = 0; k < 200; k++)
                {
                    possibleTarget = Main.npc[k];
                    distance       = (possibleTarget.Center - player.Center).Length();
                    if (distance < maxDistance && possibleTarget.active && !possibleTarget.dontTakeDamage && !possibleTarget.friendly && possibleTarget.lifeMax > 5 && !possibleTarget.immortal)
                    {
                        target      = Main.npc[k];
                        foundTarget = true;


                        maxDistance = (target.Center - player.Center).Length();
                    }
                }
            }
            else
            {
                for (int k = 0; k < 200; k++)
                {
                    possibleTarget = Main.npc[k];
                    distance       = (possibleTarget.Center - player.Center).Length();
                    if (distance < maxDistance && possibleTarget.active && !possibleTarget.dontTakeDamage && !possibleTarget.friendly && possibleTarget.lifeMax > 5 && !possibleTarget.immortal)
                    {
                        target      = Main.npc[k];
                        foundTarget = true;


                        maxDistance = (target.Center - player.Center).Length();
                    }
                }
            }
            if (runOnce)
            {
                Beam    = Main.projectile[Projectile.NewProjectile(projectile.Center, Vector2.Zero, mod.ProjectileType("MiniBeam"), projectile.damage, projectile.knockBack, projectile.owner, projectile.whoAmI, 0)];
                runOnce = false;
            }
            if (prismCount != 0)
            {
                projectile.ai[0] = 40f;
                if (foundTarget)
                {
                    flyTo = target.Center + QwertyMethods.PolarVector(maxDistance / 2f, (player.Center - target.Center).ToRotation() + (.5f * (float)Math.PI * (identity + 1)) / (prismCount + 1) - (float)Math.PI * .25f);

                    Beam.ai[1] = target.whoAmI;
                }
                else
                {
                    Beam.ai[1] = -1;
                    flyTo      = player.Center + QwertyMethods.PolarVector(projectile.ai[0], modPlayer.mythrilPrismRotation + (2f * (float)Math.PI * identity) / prismCount);
                }
                projectile.velocity = (flyTo - projectile.Center) * .1f;
                //Main.NewText(projectile.Center);/
                //projectile.Center = flyTo;
            }



            identity    = 0;
            maxDistance = beamRange * 2;
            foundTarget = false;
        }
Esempio n. 29
0
        public override void AI()
        {
            if (Main.netMode != 1)
            {
                projectile.netUpdate = true;
            }

            if (projectile.timeLeft % 10 == 0 && projectile.timeLeft < 30)
            {
                Main.PlaySound(SoundID.Item62, projectile.position);
                if (Main.netMode != 1)
                {
                    Projectile.NewProjectile(projectile.Center + QwertyMethods.PolarVector(17, projectile.rotation), QwertyMethods.PolarVector(10, projectile.rotation), mod.ProjectileType("CannonProjectile"), projectile.damage, 0f, Main.myPlayer);
                }
            }
        }
        public override void HitEffect(int hitDirection, double damage)
        {
            if (npc.life <= 0)
            {
                Vector2 pos  = npc.Center + QwertyMethods.PolarVector(98, npc.rotation) + QwertyMethods.PolarVector(120, npc.rotation + (float)Math.PI / 2);
                Gore    gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_1"), 1f)];
                gore.rotation = npc.rotation;

                pos           = npc.Center + QwertyMethods.PolarVector(98, npc.rotation) + QwertyMethods.PolarVector(120, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_2"), 1f)];
                gore.rotation = npc.rotation;

                pos           = npc.Center + QwertyMethods.PolarVector(144, npc.rotation) + QwertyMethods.PolarVector(67, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_3"), 1f)];
                gore.rotation = npc.rotation;
                pos           = npc.Center + QwertyMethods.PolarVector(144, npc.rotation) + QwertyMethods.PolarVector(-67, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_4"), 1f)];
                gore.rotation = npc.rotation;

                pos           = npc.Center + QwertyMethods.PolarVector(-15, npc.rotation) + QwertyMethods.PolarVector(102, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_5"), 1f)];
                gore.rotation = npc.rotation;
                pos           = npc.Center + QwertyMethods.PolarVector(-15, npc.rotation) + QwertyMethods.PolarVector(-102, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_6"), 1f)];
                gore.rotation = npc.rotation;

                pos           = npc.Center + QwertyMethods.PolarVector(-15, npc.rotation) + QwertyMethods.PolarVector(0, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_7"), 1f)];
                gore.rotation = npc.rotation;
                pos           = npc.Center + QwertyMethods.PolarVector(-15, npc.rotation) + QwertyMethods.PolarVector(0, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_8"), 1f)];
                gore.rotation = npc.rotation;
                pos           = npc.Center + QwertyMethods.PolarVector(-154, npc.rotation) + QwertyMethods.PolarVector(0, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_9"), 1f)];
                gore.rotation = npc.rotation;
                pos           = npc.Center + QwertyMethods.PolarVector(77, npc.rotation) + QwertyMethods.PolarVector(0, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_10"), 1f)];
                gore.rotation = npc.rotation;
                pos           = npc.Center + QwertyMethods.PolarVector(166, npc.rotation) + QwertyMethods.PolarVector(0, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_11"), 1f)];
                gore.rotation = npc.rotation;

                pos           = npc.Center + QwertyMethods.PolarVector(-65, npc.rotation) + QwertyMethods.PolarVector(79, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_12"), 1f)];
                gore.rotation = npc.rotation;
                pos           = npc.Center + QwertyMethods.PolarVector(-65, npc.rotation) + QwertyMethods.PolarVector(-79, npc.rotation + (float)Math.PI / 2);
                gore          = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_13"), 1f)];
                gore.rotation = npc.rotation;
            }
        }