Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 2
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
        }
Exemplo n.º 3
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);
        }