Beispiel #1
0
        public override void PostUpdate()
        {
            //TidePoints = EnemyKills / 2;
            if (TidePoints >= 100)
            {
                TidePoints = 0;
                EnemyKills = 0;
                TideWaveIncrease();
                SendPacket(mod);
            }

            if (TheTide && TideWave == 5)
            {
                if (!NPC.AnyNPCs(ModContent.NPCType <Rylheian>()))
                {
                    Player player = Main.rand.Next(Main.player.Where(x => x.active && !x.dead && x.ZoneBeach).ToArray());

                    NPC npc = Main.npc[NPC.NewNPC((int)player.Center.X, (int)player.Center.Y - 400, ModContent.NPCType <Rylheian>(), 0, 2, 1, 0, 0, player.whoAmI)];
                    DustHelper.DrawDiamond(new Vector2(npc.Center.X, npc.Center.Y), 173, 8);
                    DustHelper.DrawTriangle(new Vector2(npc.Center.X, npc.Center.Y), 173, 8);
                    Main.PlaySound(SoundID.Zombie, npc.Center, 89);

                    if (Main.netMode != NetmodeID.SinglePlayer)
                    {
                        NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI);
                    }
                }
            }
        }
Beispiel #2
0
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
		{
			if (type == ProjectileID.WoodenArrowFriendly) {
				type = ModContent.ProjectileType<ShadowmoorProjectile>();
                damage = (int)(damage * .75f);
            }
			else
            {
                float angle = Main.rand.NextFloat(MathHelper.PiOver4, -MathHelper.Pi - MathHelper.PiOver4);
                Vector2 spawnPlace = Vector2.Normalize(new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle))) * 20f;
                if (Collision.CanHit(position, 0, 0, position + spawnPlace, 0, 0))
                {
                    position += spawnPlace;
                }

                Vector2 velocity = Vector2.Normalize(Main.MouseWorld - position) * item.shootSpeed;
                DustHelper.DrawDiamond(new Vector2(position.X, position.Y), 173, 2, .8f, .75f);
                int p1 = Projectile.NewProjectile(position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType<ShadowmoorProjectile>(), damage, knockBack, 0, 0.0f, 0.0f);

            }
            for (int I = 0; I < 4; I++)
            {
                float angle = Main.rand.NextFloat(MathHelper.PiOver4, -MathHelper.Pi - MathHelper.PiOver4);
                Vector2 spawnPlace = Vector2.Normalize(new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle))) * 20f;
                if (Collision.CanHit(position, 0, 0, position + spawnPlace, 0, 0))
                {
                    position += spawnPlace;
                }

                Vector2 velocity = Vector2.Normalize(Main.MouseWorld - position) * item.shootSpeed;
                DustHelper.DrawDiamond(new Vector2(position.X, position.Y), 173, 2, .8f, .75f);
                int p = Projectile.NewProjectile(position.X, position.Y, velocity.X, velocity.Y, type, damage, knockBack, 0, 0.0f, 0.0f);
            }
			return false;
		}
Beispiel #3
0
        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 shardType;

            shardType = Main.rand.Next(new int[] { ModContent.ProjectileType <CobaltStaffProj>(), ModContent.ProjectileType <CobaltStaffProj1>() });

            //set the spawn position to the first solid tile in the direction of the cursor, or the cursor, whichever is closer
            float[] scanarray = new float[3];
            float   dist      = player.Distance(Main.MouseWorld);                                        //set the maximum distance to the distance between the player and the cursor

            Collision.LaserScan(player.Center, player.DirectionTo(Main.MouseWorld), 0, dist, scanarray); //scan to find the first solid tile in the direction of the cursor
            dist = 0;
            foreach (float array in scanarray)                                                           //make the distance the average of the samples
            {
                dist += array / (scanarray.Length);
            }

            Vector2 spawnpos = player.Center + player.DirectionTo(Main.MouseWorld) * dist;

            Projectile p = Projectile.NewProjectileDirect(spawnpos + Main.rand.NextVector2Square(-20, 20), Main.rand.NextVector2Circular(10, 10), shardType, damage, knockBack, player.whoAmI);

            p.scale     = Main.rand.NextFloat(.4f, 1.1f);
            p.netUpdate = true;
            DustHelper.DrawDiamond(spawnpos, 48, 1.5f, 1.2f, 1f);
            return(false);
        }
        public override void AI()
        {
            if (!checkColor)
            {
                switch (Main.rand.Next(3))
                {
                case 0:
                    colorField = new Color(191, 145, 255);
                    break;

                case 1:
                    colorField = new Color(215, 135, 255);
                    break;

                case 2:
                    colorField = new Color(223, 94, 255);
                    break;
                }
                checkColor = true;
            }
            if (projectile.timeLeft >= 290)
            {
                projectile.tileCollide = false;
            }
            else
            {
                projectile.tileCollide = true;
            }
            Lighting.AddLight(projectile.position, 0.205f * 1.85f, 0.135f * 1.85f, 0.255f * 1.85f);
            num += .4f;
            projectile.rotation = projectile.velocity.ToRotation() + 1.57f;
            float distance = Vector2.Distance(projectile.Center, Main.MouseWorld);

            if (distance < 20f)
            {
                DustHelper.DrawDiamond(new Vector2(projectile.Center.X, projectile.Center.Y), 173, 4, .8f, .75f);
                Main.PlaySound(4, (int)projectile.position.X, (int)projectile.position.Y, 6);
                if (!escaped && Main.rand.NextBool(2))
                {
                    projectile.ai[1] = 10;
                }
                escaped = true;
            }
            if (projectile.ai[1] == 10)
            {
                Vector2 currentSpeed = new Vector2(projectile.velocity.X, projectile.velocity.Y);
                projectile.velocity = currentSpeed.RotatedBy(Main.rand.Next(-3, 3) * (Math.PI / 40));
            }
        }
Beispiel #5
0
        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 shardType;

            shardType = Main.rand.Next(new int[] { ModContent.ProjectileType <CobaltStaffProj>(), ModContent.ProjectileType <CobaltStaffProj1>() });
            float[] scanarray = new float[3];
            float   dist      = player.Distance(Main.MouseWorld);

            Collision.LaserScan(player.Center, player.DirectionTo(Main.MouseWorld), 0, dist, scanarray);
            dist = 0;
            foreach (float array in scanarray)
            {
                dist += array / (scanarray.Length);
            }
            Vector2    spawnpos = player.Center + player.DirectionTo(Main.MouseWorld) * dist;
            Projectile p        = Projectile.NewProjectileDirect(spawnpos + Main.rand.NextVector2Square(-20, 20), Main.rand.NextVector2Circular(10, 10), shardType, damage, knockBack, player.whoAmI);

            p.scale     = Main.rand.NextFloat(.4f, 1.1f);
            p.netUpdate = true;
            DustHelper.DrawDiamond(spawnpos, 48, 1.5f, 1.2f, 1f);
            return(false);
        }
Beispiel #6
0
        public override void AI()
        {
            if (npc.ai[1] != 0)
            {
                alphaCounter += 0.04f;
            }
            else if (alphaCounter > 0)
            {
                alphaCounter -= 0.08f;
            }
            if (npc.ai[1] == 0 && npc.life < npc.lifeMax / 3 && npc.ai[0] % 2 == 0)
            {
                npc.ai[0]++;
            }
            npc.TargetClosest();
            Player player = Main.player[npc.target];

            npc.ai[0]++;
            int dust = Dust.NewDust(npc.position, npc.width, npc.height, 173);

            npc.spriteDirection = npc.direction;
            if (npc.ai[0] % 400 == 100 && Main.netMode != NetmodeID.MultiplayerClient)
            {
                int  distance   = 500;
                bool teleported = false;
                while (!teleported)
                {
                    npc.ai[3] = Main.rand.Next(360);
                    double anglex = Math.Sin(npc.ai[3] * (Math.PI / 180));
                    double angley = Math.Cos(npc.ai[3] * (Math.PI / 180));
                    npc.position.X = player.Center.X + (int)(distance * anglex);
                    npc.position.Y = player.Center.Y + (int)(distance * angley);
                    if (Main.tile[(int)(npc.position.X / 16), (int)(npc.position.Y / 16)].active() || Main.tile[(int)(npc.Center.X / 16), (int)(npc.Center.Y / 16)].active())
                    {
                        npc.alpha = 255;
                    }
                    else
                    {
                        teleported = true;
                        npc.alpha  = 0;
                    }
                }
                npc.netUpdate = true;
            }
            if (npc.ai[0] % 400 == 104)
            {
                Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 8);
                DustHelper.DrawDiamond(npc.Center, 173, 12);
                npc.netUpdate = true;
            }
            float num395 = Main.mouseTextColor / 200f - 0.35f;

            num395   *= 0.2f;
            npc.scale = num395 + 0.95f;
            if (!Main.raining)
            {
                Main.cloudAlpha += .005f;
                if (Main.cloudAlpha >= .5f)
                {
                    Main.cloudAlpha = .5f;
                }
            }
            if (npc.ai[0] % 400 == 200)
            {
                npc.ai[1]     = Main.rand.Next(3) + 1;
                npc.ai[2]     = Main.rand.NextFloat(0.785f);
                npc.netUpdate = true;
            }

            #region Phase 1
            if (npc.ai[0] % 400 == 316 && npc.ai[1] == 1)
            {
                Main.PlaySound(2, npc.Center, 109);
                for (npc.ai[2] = 0; npc.ai[2] < 6.29; npc.ai[2] += 0.785f)
                {
                    Vector2 offset    = new Vector2((float)Math.Cos(npc.ai[2]), (float)Math.Sin(npc.ai[2])) * 90f;
                    Vector2 direction = player.Center - (npc.Center + offset);
                    direction.Normalize();
                    direction *= 19;

                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile proj = Projectile.NewProjectileDirect(npc.Center + offset, direction, ModContent.ProjectileType <RyBolt>(), npc.damage / 2, 0, Main.myPlayer);
                        proj.netUpdate = true;
                    }
                }
                npc.ai[1]     = 0;
                npc.netUpdate = true;
            }
            if (npc.ai[1] == 1)
            {
                if (npc.ai[0] % 12 == 0 && npc.ai[0] % 400 < 300)
                {
                    Main.PlaySound(2, npc.Center, 8);
                    Vector2 offset = new Vector2((float)Math.Cos(npc.ai[2]), (float)Math.Sin(npc.ai[2])) * 90f;
                    DustHelper.DrawTriangle(npc.Center + offset, 173, 4);
                    npc.ai[2]    += 0.785f;
                    npc.netUpdate = true;
                }
            }
            #endregion
            #region phase 2
            if (npc.ai[1] == 2)
            {
                if (npc.ai[0] % 15 == 10 && Main.netMode != NetmodeID.MultiplayerClient)
                {
                    int laser = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0, 10, ModContent.ProjectileType <RyTentacle>(), npc.damage / 2, 0);
                    Main.projectile[laser].netUpdate = true;
                    npc.netUpdate = true;
                }
                if (npc.ai[0] % 400 == 390)
                {
                    npc.ai[1]     = 0;
                    npc.netUpdate = true;
                }
            }
            #endregion
            #region phase 3
            if (npc.ai[1] == 3)
            {
                if (npc.ai[0] % 25 == 10)
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        npc.ai[3] = Main.rand.Next(360);
                        double  squidAnglex = Math.Sin(npc.ai[3] * (Math.PI / 180));
                        double  squidAngley = 0 - Math.Abs(Math.Cos(npc.ai[3] * (Math.PI / 180)));
                        Vector2 direction   = player.Center - new Vector2(player.Center.X + (int)(500 * squidAnglex), player.Center.Y + (int)(500 * squidAngley));
                        direction.Normalize();
                        direction *= 19;
                        int squid = Projectile.NewProjectile(player.Center.X + (int)(500 * squidAnglex), player.Center.Y + (int)(500 * squidAngley), direction.X, direction.Y, ModContent.ProjectileType <TentacleSquid>(), npc.damage / 2, 0);
                        Main.projectile[squid].netUpdate = true;
                        npc.netUpdate = true;
                    }
                }
                if (npc.ai[0] % 25 == 11)
                {
                    DustHelper.DrawTriangle(new Vector2(player.Center.X + (int)(500 * Math.Sin(npc.ai[3] * (Math.PI / 180))), player.Center.Y + (int)(500 * (0 - Math.Abs(Math.Cos(npc.ai[3] * (Math.PI / 180)))))), 173, 3);
                }
                if (npc.ai[0] % 400 == 390)
                {
                    npc.ai[1]     = 0;
                    npc.netUpdate = true;
                }
            }
            #endregion
        }
Beispiel #7
0
 private static void Leech(Player player)
 {
     player.AddBuff(SpiritMod.instance.BuffType("SanguineRegen"), Main.rand.Next(2, 4) * 60);
     DustHelper.DrawDiamond(player.Center, ModContent.DustType <Dusts.Blood>(), 3);
     Main.PlaySound(SoundID.Item, (int)player.Center.X, (int)player.Center.Y, 3, 0.75f, -0.5f);
 }
Beispiel #8
0
        public override void AI()
        {
            npc.spriteDirection = npc.direction;
            Player target   = Main.player[npc.target];
            int    distance = (int)Math.Sqrt((npc.Center.X - target.Center.X) * (npc.Center.X - target.Center.X) + (npc.Center.Y - target.Center.Y) * (npc.Center.Y - target.Center.Y));

            if (distance < 200)
            {
                if (!aggroed)
                {
                    Main.PlaySound(SoundID.Zombie, (int)npc.position.X, (int)npc.position.Y, 53);
                }
                aggroed = true;
            }

            if (!aggroed)
            {
                if (npc.localAI[0] == 0f)
                {
                    npc.localAI[0] = npc.Center.Y;
                    npc.netUpdate  = true;                    //localAI probably isnt affected by this... buuuut might as well play it safe
                }
                if (npc.Center.Y >= npc.localAI[0])
                {
                    npc.localAI[1] = -1f;
                    npc.netUpdate  = true;
                }
                if (npc.Center.Y <= npc.localAI[0] - 2f)
                {
                    npc.localAI[1] = 1f;
                    npc.netUpdate  = true;
                }
                npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + 0.009f * npc.localAI[1], -.25f, .25f);
                timer++;
                if (timer == 4)
                {
                    frame++;
                    timer = 0;
                }
                if (frame >= 4)
                {
                    frame = 1;
                }
            }
            else
            {
                timer++;
                if (timer == 4)
                {
                    frame++;
                    timer = 0;
                }
                if (frame >= 3)
                {
                    frame = 0;
                }
                Player player = Main.player[npc.target];

                if (npc.Center.X >= player.Center.X && moveSpeed >= -30)                 // flies to players x position
                {
                    moveSpeed--;
                }

                if (npc.Center.X <= player.Center.X && moveSpeed <= 30)
                {
                    moveSpeed++;
                }

                npc.velocity.X = moveSpeed * 0.08f;

                if (npc.Center.Y >= player.Center.Y - HomeY && moveSpeedY >= -20)                 //Flies to players Y position
                {
                    moveSpeedY--;
                    HomeY = 165f;
                }

                if (npc.Center.Y <= player.Center.Y - HomeY && moveSpeedY <= 20)
                {
                    moveSpeedY++;
                }

                npc.velocity.Y = moveSpeedY * 0.1f;
                if (Main.rand.Next(250) == 1)
                {
                    HomeY = -25f;
                }

                ++npc.ai[0];
                if (NPC.CountNPCS(ModContent.NPCType <IllusionistSpectre>()) < 3)
                {
                    if (npc.ai[0] == 240 || npc.ai[0] == 480 || npc.ai[0] == 720)
                    {
                        Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 8);
                        Main.PlaySound(SoundID.Zombie, (int)npc.position.X, (int)npc.position.Y, 53);
                        if (Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            NPC.NewNPC((int)npc.position.X + npc.width / 2, (int)npc.Center.Y - 16, ModContent.NPCType <IllusionistSpectre>(), 0, 0, 0, 0, 0, 255);
                        }
                        float ScaleMult = 2.33f;
                        switch (Main.rand.Next(3))
                        {
                        case 0:
                            //DustHelper.DrawStar(new Vector2(npc.Center.X, npc.Center.Y - 30), 180, pointAmount: 5, mainSize: 2.25f * ScaleMult, dustDensity: 2, pointDepthMult: 0.3f, noGravity: true);
                            DustHelper.DrawTriangle(new Vector2(npc.Center.X, npc.Center.Y - 30), 180, 3);
                            break;

                        case 1:
                            DustHelper.DrawTriangle(new Vector2(npc.Center.X, npc.Center.Y - 30), 180, 3);
                            break;

                        case 2:
                            DustHelper.DrawDiamond(new Vector2(npc.Center.X, npc.Center.Y - 30), 180, 3);
                            break;
                        }
                    }

                    if (npc.ai[0] >= 230 && npc.ai[0] <= 250 || npc.ai[0] >= 470 && npc.ai[0] <= 485 || npc.ai[0] >= 710 && npc.ai[0] <= 725)
                    {
                        frame = 4;
                    }
                }
                if (npc.ai[0] >= 720)
                {
                    npc.ai[0] = 0;
                }
            }

            Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.122f, .5f, .48f);
        }