コード例 #1
0
        public override void Kill(int timeLeft)
        {
            Player  player   = Main.player[projectile.owner];
            Vector2 velocity = AntiarisHelper.VelocityToPoint(Main.MouseWorld, projectile.Center, 14);

            Projectile.NewProjectile(projectile.Center.X + Main.rand.Next(-150, 150), projectile.Center.Y + Main.rand.Next(-150, 150), velocity.X, velocity.Y, ModContent.ProjectileType <TheRedShard>(), (int)(36 * player.meleeDamage), 6.0f, projectile.owner, 0.0f, 0.0f);
        }
コード例 #2
0
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            AntiarisPlayer aPlayer = player.GetModPlayer <AntiarisPlayer>(mod);

            aPlayer.aItems = true;
            if (!player.buffType.Contains(ModContent.BuffType <Recharge>()))
            {
                if (AntiarisMod.adventurerKey.JustPressed)
                {
                    player.GetModPlayer <QuestSystem>(mod).CurrentQuest = -1;
                    AntiarisHelper.CreateDust(player, 64, 20);
                    SoundEngine.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Items/AdventurerItem"), player.position);
                    for (int l = 3; l < 8 + player.extraAccessorySlots; l++)
                    {
                        if (player.armor[l].type == ModContent.ItemType <CelestialManual>())
                        {
                            int newLife = Main.rand.Next(35, 55);
                            player.statLife += newLife;
                            player.HealEffect(newLife);
                        }
                    }
                    player.AddBuff(ModContent.BuffType <Recharge>(), 7200);
                }
            }
        }
コード例 #3
0
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            var aPlayer = player.GetModPlayer <AntiarisPlayer>(mod);

            aPlayer.aItems = true;
            if (!player.buffType.Contains(mod.BuffType("Recharge")))
            {
                if (player.showLastDeath)
                {
                    if (Antiaris.adventurerKey.JustPressed)
                    {
                        var teleport = player.lastDeathPostion;
                        player.Teleport(teleport, -69);
                        player.Center = teleport;
                        AntiarisHelper.CreateDust(player, 64, 20);
                        Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Items/AdventurerItem"), player.position);
                        for (var l = 3; l < 8 + player.extraAccessorySlots; l++)
                        {
                            if (player.armor[l].type == mod.ItemType("CelestialManual"))
                            {
                                var newLife = Main.rand.Next(35, 55);
                                player.statLife += newLife;
                                player.HealEffect(newLife);
                            }
                        }
                        player.AddBuff(mod.BuffType("Recharge"), 2000);
                        NetMessage.SendData(65, -1, -1, null, 0, player.whoAmI, teleport.X, teleport.Y, 1, 0, 0);
                    }
                }
            }
        }
コード例 #4
0
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            var aPlayer = player.GetModPlayer <AntiarisPlayer>(mod);

            aPlayer.aItems = true;
            if (!player.buffType.Contains(mod.BuffType("Recharge")))
            {
                if (Antiaris.adventurerKey.JustPressed)
                {
                    player.TeleportationPotion();
                    AntiarisHelper.CreateDust(player, 64, 20);
                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Items/AdventurerItem"), player.position);
                    for (var l = 3; l < 8 + player.extraAccessorySlots; l++)
                    {
                        if (player.armor[l].type == mod.ItemType("CelestialManual"))
                        {
                            var newLife = Main.rand.Next(35, 55);
                            player.statLife += newLife;
                            player.HealEffect(newLife);
                        }
                    }
                    player.AddBuff(mod.BuffType("Recharge"), 2000);
                }
            }
        }
コード例 #5
0
        public override bool PreAI()
        {
            npc.TargetClosest(true);
            int boss = (int)npc.ai[0];

            if (boss < 0 || boss >= 200 || !Main.npc[boss].active || Main.npc[boss].type != ModContent.NPCType <TowerKeeper2>())
            {
                npc.active = false;
                return(false);
            }
            this.rot     -= 0.02f;
            npc.netUpdate = true;
            Vector2 v = Main.npc[boss].Center - npc.Center;

            v.Normalize();
            v           *= 9f;
            npc.rotation = Utils.ToRotation(v);
            NPC npc2 = Main.npc[(int)npc.ai[0]];

            npc.Center = npc2.Center + AntiarisHelper.RotateVector(new Vector2(), this.rotVec, this.rot + npc.ai[2] * 0.628f);
            npc.ai[3]++;
            if (npc.ai[3] % 10.0 == 1.0 && Main.rand.Next(2) == 0 && Main.netMode != NetmodeID.MultiplayerClient)
            {
                float   speed = (float)(3.0 + Main.rand.NextFloat() * 6.0);
                Vector2 start = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                Projectile.NewProjectile(Main.npc[boss].Center.X, Main.npc[boss].Center.Y, start.X * speed, start.Y * speed, ModContent.ProjectileType <Energy>(), 15, 0.0f, Main.myPlayer, Main.npc[boss].Center.X, Main.npc[boss].Center.Y - 42f);
            }
            return(false);
        }
コード例 #6
0
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            AntiarisPlayer aPlayer = player.GetModPlayer <AntiarisPlayer>(mod);

            aPlayer.aItems = true;
            if (!player.buffType.Contains(ModContent.BuffType <Recharge>()))
            {
                if (player.showLastDeath)
                {
                    if (AntiarisMod.adventurerKey.JustPressed)
                    {
                        Microsoft.Xna.Framework.Vector2 teleport = player.lastDeathPostion;
                        player.Teleport(teleport, -69);
                        player.Center = teleport;
                        AntiarisHelper.CreateDust(player, 64, 20);
                        SoundEngine.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Items/AdventurerItem"), player.position);
                        for (int l = 3; l < 8 + player.extraAccessorySlots; l++)
                        {
                            if (player.armor[l].type == ModContent.ItemType <CelestialManual>())
                            {
                                int newLife = Main.rand.Next(35, 55);
                                player.statLife += newLife;
                                player.HealEffect(newLife);
                            }
                        }
                        player.AddBuff(ModContent.BuffType <Recharge>(), 2000);
                        NetMessage.SendData(MessageID.Teleport, -1, -1, null, 0, player.whoAmI, teleport.X, teleport.Y, 1, 0, 0);
                    }
                }
            }
        }
コード例 #7
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (Main.myPlayer != projectile.owner)
            {
                return;
            }
            projectile.scale = projectile.Opacity;
            if (player.inventory[player.selectedItem].type == ModContent.ItemType <RoyalStave>() && !pos)
            {
                if (!(player.itemAnimation < player.inventory[player.selectedItem].useAnimation - 1))
                {
                    Vector2 velocity = AntiarisHelper.VelocityToPoint(projectile.Center, Main.MouseWorld, 6);
                    Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, velocity.X, velocity.Y, ModContent.ProjectileType <RoyalCrystalSpike>(), projectile.damage, projectile.knockBack * 0.5f, projectile.owner);
                }
            }
            if (pos)
            {
                pos = false;
                Vector2 vector;
                vector.X             = Main.MouseWorld.X - 30f;
                vector.Y             = Main.MouseWorld.Y - 30f;
                projectile.netUpdate = true;
                projectile.position  = vector;
            }
        }
コード例 #8
0
        public override void Kill(int timeLeft)
        {
            Vector2 velocity = AntiarisHelper.VelocityToPoint(projectile.Center, Main.MouseWorld, 8);

            SoundEngine.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Projectiles/Explosion"), projectile.position);
            Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, velocity.X, velocity.Y, ModContent.ProjectileType <TerriBlade>(), projectile.damage, projectile.knockBack * 0.5f, projectile.owner, 0.0f, 0.0f);
            for (int i = 0; i < 6; ++i)
            {
                Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width, projectile.height, 59, projectile.velocity.X * 0.24f, projectile.velocity.Y * 0.24f, 59, new Color(), 1.4f);
            }
            for (int i = 0; i < 6; ++i)
            {
                Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width, projectile.height, 62, projectile.velocity.X * 0.24f, projectile.velocity.Y * 0.24f, 62, new Color(), 1.4f);
            }
            for (int i = 0; i < 6; ++i)
            {
                Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width, projectile.height, 65, projectile.velocity.X * 0.24f, projectile.velocity.Y * 0.24f, 65, new Color(), 1.4f);
            }
        }
コード例 #9
0
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            AntiarisPlayer aPlayer = player.GetModPlayer <AntiarisPlayer>(mod);

            aPlayer.aItems     = true;
            player.pStone      = true;
            player.longInvince = true;
            if (!player.buffType.Contains(ModContent.BuffType <Recharge>()))
            {
                if (AntiarisMod.adventurerKey.JustPressed)
                {
                    var teleportPos = new Vector2();
                    teleportPos.X = Main.mouseX + Main.screenPosition.X - player.width / 2;
                    teleportPos.Y = player.gravDir != 1 ? (Main.screenPosition.Y + Main.screenHeight - Main.mouseY) : (Main.mouseY + Main.screenPosition.Y - player.height);
                    if (teleportPos.X > 50 && teleportPos.X < (double)(Main.maxTilesX * 16 - 50) && (teleportPos.Y > 50 && teleportPos.Y < (double)(Main.maxTilesY * 16 - 55)))
                    {
                        int tileX = (int)(teleportPos.X / 16f);
                        int tileY = (int)(teleportPos.Y / 16f);
                        if (!Collision.SolidCollision(teleportPos, player.width, player.height))
                        {
                            AntiarisHelper.TeleportTo(player, teleportPos);
                            AntiarisHelper.CreateDust(player, 64, 20);
                            SoundEngine.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Items/AdventurerItem"), player.position);
                            for (int l = 3; l < 8 + player.extraAccessorySlots; l++)
                            {
                                int newLife = Main.rand.Next(35, 55);
                                if (player.armor[l].type == ModContent.ItemType <CelestialManual>())
                                {
                                    player.statLife += newLife;
                                    player.HealEffect(newLife);
                                }
                            }
                            player.statLife += 15;
                            NetMessage.SendData(MessageID.Teleport, -1, -1, null, 0, player.whoAmI, teleportPos.X, teleportPos.Y, 1, 0, 0);
                            player.AddBuff(ModContent.BuffType <Recharge>(), 840);
                        }
                    }
                }
            }
        }
コード例 #10
0
        public override bool PreAI()
        {
            npc.TargetClosest(true);
            int boss = (int)npc.ai[0];

            if (boss < 0 || boss >= 200 || !Main.npc[boss].active || Main.npc[boss].type != mod.NPCType("TowerKeeper2"))
            {
                npc.active = false;
                return(false);
            }
            this.rot     -= 0.02f;
            npc.netUpdate = true;
            Vector2 v = Main.npc[boss].Center - npc.Center;

            v.Normalize();
            v           *= 9f;
            npc.rotation = Utils.ToRotation(v);
            NPC npc2 = Main.npc[(int)npc.ai[0]];

            npc.Center = npc2.Center + AntiarisHelper.RotateVector(new Vector2(), this.rotVec, this.rot + npc.ai[2] * 0.628f);
            return(false);
        }
コード例 #11
0
        public override void AI()
        {
            if (projectile.timeLeft <= 100)
            {
                projectile.alpha += 2;
            }
            this.rot -= 0.09f;
            for (var k = 0; k < 1; k++)
            {
                var dust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 62, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, Color.White, 1.5f);
                Main.dust[dust].noGravity   = true;
                Main.dust[dust].velocity.X += 0.6f * -projectile.direction;
            }
            projectile.rotation += 0.05f / projectile.Opacity;
            Projectile projectile2 = Main.projectile[(int)projectile.ai[0]];

            if (!projectile2.active)
            {
                projectile.Kill();
            }
            projectile.Center    = projectile2.Center + AntiarisHelper.RotateVector(new Vector2(), this.rotVec, this.rot + projectile.ai[1] * 0.628f);
            projectile.netUpdate = true;
        }
コード例 #12
0
        public override void AI()
        {
            Lighting.AddLight(npc.Center, 1f, 0.6f, 0.3f);
            Player player = Main.player[npc.target];

            timer++;
            if (timer % 10 == 0)
            {
                frame++;
            }
            if (timer % 80 == 0)
            {
                attacking = true;
            }
            if (frame > 3 && !attacking)
            {
                frame = 0;
            }
            if ((frame < 4 || frame > 7) && attacking)
            {
                frame = 4;
            }
            if (attacking)
            {
                if (timer == 110)
                {
                    var velocity = AntiarisHelper.VelocityToPoint(npc.Center, AntiarisHelper.RandomPointInArea(new Vector2(player.Center.X, player.Center.Y), new Vector2(player.Center.X + 20, player.Center.Y + 20)), 12);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, mod.ProjectileType("WrathSkull"), Main.rand.Next(20, 30), 1f);
                    Main.PlaySound(SoundID.Item8);
                    npc.position.X = (Main.player[npc.target].position.X - 500) + Main.rand.Next(1000);
                    npc.position.Y = (Main.player[npc.target].position.Y - 500) + Main.rand.Next(1000);
                    attacking      = false;
                    frame          = 0;
                    timer          = 0;
                }
            }
        }
コード例 #13
0
        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            var aPlayer = player.GetModPlayer <AntiarisPlayer>(mod);

            aPlayer.aItems = true;
            if (!player.buffType.Contains(mod.BuffType("Recharge")))
            {
                if (Antiaris.adventurerKey.JustPressed)
                {
                    var teleportPos = new Vector2();
                    teleportPos.X = Main.mouseX + Main.screenPosition.X - player.width / 2;
                    teleportPos.Y = player.gravDir != 1 ? (Main.screenPosition.Y + Main.screenHeight - Main.mouseY) : (Main.mouseY + Main.screenPosition.Y - player.height);
                    if (teleportPos.X > 50 && teleportPos.X < (double)(Main.maxTilesX * 16 - 50) && (teleportPos.Y > 50 && teleportPos.Y < (double)(Main.maxTilesY * 16 - 55)))
                    {
                        var tileX = (int)(teleportPos.X / 16f);
                        var tileY = (int)(teleportPos.Y / 16f);
                        if (((int)Main.tile[tileX, tileY].wall != 87 || (double)tileY <= Main.worldSurface || NPC.downedPlantBoss) && !Collision.SolidCollision(teleportPos, player.width, player.height))
                        {
                            AntiarisHelper.TeleportTo(player, teleportPos);
                            AntiarisHelper.CreateDust(player, 64, 20);
                            Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Items/AdventurerItem"), player.position);
                            for (var l = 3; l < 8 + player.extraAccessorySlots; l++)
                            {
                                if (player.armor[l].type == mod.ItemType("CelestialManual"))
                                {
                                    var newLife = Main.rand.Next(35, 55);
                                    player.statLife += newLife;
                                    player.HealEffect(newLife);
                                }
                            }
                            NetMessage.SendData(65, -1, -1, null, 0, player.whoAmI, teleportPos.X, teleportPos.Y, 1, 0, 0);
                            player.AddBuff(mod.BuffType("Recharge"), 600);
                        }
                    }
                }
            }
        }
コード例 #14
0
        // notes for aiStyle 99:
        // localAI[0] is used for timing up to YoyosLifeTimeMultiplier
        // localAI[1] can be used freely by specific types
        // ai[0] and ai[1] usually point towards the x and y world coordinate hover point
        // ai[0] is -1f once YoyosLifeTimeMultiplier is reached, when the player is stoned/frozen, when the yoyo is too far away, or the player is no longer clicking the shoot button.
        // ai[0] being negative makes the yoyo move back towards the player
        // Any AI method can be used for dust, spawning projectiles, etc specific to your yoyo.

        void Shoot()
        {
            if (--TimeToShoot <= 0)
            {
                TimeToShoot = ShootRate;
                if (ShootType == -1)
                {
                    ShootType = mod.ProjectileType(ShootTypeMod);
                }

                float NearestNPCDist = ShootDistance;
                int   NearestNPC     = -1;
                foreach (NPC npc in Main.npc)
                {
                    if (!npc.active)
                    {
                        continue;
                    }
                    if (npc.friendly || npc.lifeMax <= 5 || npc.immortal)
                    {
                        continue;
                    }
                    if (NearestNPCDist == -1 || npc.Distance(projectile.Center) < NearestNPCDist && Collision.CanHitLine(projectile.Center, 16, 16, npc.Center, 16, 16))
                    {
                        NearestNPCDist = npc.Distance(projectile.Center);
                        NearestNPC     = npc.whoAmI;
                    }
                }
                if (NearestNPC == -1)
                {
                    return;
                }
                Vector2 Velocity = AntiarisHelper.VelocityToPoint(projectile.Center, Main.npc[NearestNPC].Center, ShootSpeed);
                Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, Velocity.X, Velocity.Y, ShootType, ShootDamage, ShootKnockback, projectile.owner);
            }
        }
コード例 #15
0
        /*public override void AI()
         * {
         *  var player = Main.player[npc.target];
         *  var anyPlayer = Main.player[Main.myPlayer];
         *  //anyPlayer.
         *  anyPlayer.AddBuff(BuffID.WaterWalking, 60);
         *  frameTimer++;
         *  aiTimer++;
         *  npc.rotation = 0f;
         *  npc.direction = npc.spriteDirection;
         *  if ((double)player.position.X > (double)npc.position.X)
         *      npc.spriteDirection = 1;
         *  else if ((double)player.position.X < (double)npc.position.X)
         *      npc.spriteDirection = -1;
         *
         *  if (frameTimer % 10 == 0)
         *  {
         *      frame++;
         *      frameTimer = 0;
         *  }
         *  if (frame > 4 && !attackAnim)
         *  {
         *      frame = 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 > 10)
         *          {
         *              npc.timeLeft = 10;
         *          }
         *          return;
         *      }
         *  }
         *
         *  if (aiTimer > 240 && !attack)
         *  {
         *      attack = true;
         *      if (aiTimer < 265)
         *      {
         *          attackAnim = true;
         *          npc.velocity.X = 0;
         *          npc.velocity.Y = 0;
         *      }
         *      if (attackAnim && frame > 9)
         *      {
         *          frame = 0;
         *          attackAnim = false;
         *          aiTimer = 0;
         *      }
         *  }
         *
         *  if (attack)
         *  {
         *      switch (Main.rand.Next(1))
         *      {
         *          case 0:
         *              {
         *                  teleportingTimer++;
         *                  if (teleportingTimer == 120)
         *                  {
         *                      positionX = npc.position.X;
         *                      positionY = npc.position.Y;
         *                  }
         *                  if (teleportingTimer % 160 == 0)
         *                  {
         *                      teleportCount++;
         *                      Main.NewText("Teleport number" + teleportCount);
         *                      bossOldPosX = npc.position.X;
         *                      bossOldPosY = npc.position.Y;
         *
         *                      playerOldPosX = player.position.X;
         *                      playerOldPosY = player.position.Y;
         *                      Main.PlaySound(SoundID.Item8, npc.position);
         *                      for (int i = 0; i < 10; i++)
         *                      {
         *                          int dust = Dust.NewDust(new Vector2((float)npc.position.X, (float)npc.position.Y), npc.width, npc.height, 56, npc.velocity.X + Main.rand.Next(-10, 10), npc.velocity.Y + Main.rand.Next(-10, 10), 5, npc.color, 2.6f);
         *                          Main.dust[dust].noGravity = true;
         *                      }
         *                      Main.PlaySound(SoundID.Item8, player.position);
         *                      for (int i = 0; i < 10; i++)
         *                      {
         *                          int dust = Dust.NewDust(new Vector2((float)player.position.X, (float)player.position.Y), player.width, player.height, 56, player.velocity.X + Main.rand.Next(-10, 10), player.velocity.Y + Main.rand.Next(-10, 10), 5, Color.LightBlue, 2.6f);
         *                          Main.dust[dust].noGravity = true;
         *                      }
         *                      player.position.X = bossOldPosX;
         *                      player.position.Y = bossOldPosY;
         *                      npc.position.X = playerOldPosX;
         *                      npc.position.Y = playerOldPosY;
         *
         *                      var velocity = AntiarisHelper.VelocityToPoint(npc.Center, AntiarisHelper.RandomPointInArea(new Vector2(player.Center.X - 10, player.Center.Y - 10), new Vector2(player.Center.X + 20, player.Center.Y + 20)), Main.expertMode ? 16 : 20);
         *                      var shark = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, 408, Main.rand.Next(20, 30), 1f);
         *                      Main.projectile[shark].friendly = false;
         *                      Main.projectile[shark].hostile = true;
         *                      Main.projectile[shark].tileCollide = false;
         *                      Main.projectile[shark].timeLeft = 300;
         *                  }
         *                  if (teleportCount == (Main.expertMode ? 7 : 6))
         *                  {
         *                      attack = false;
         *                      teleportCount = 0;
         *                  }
         *              }
         *              break;
         *      }
         *  }
         * }*/

        public override void AI()
        {
            aiTimer++;
            frameTimer++;
            Player player = Main.player[npc.target];

            player.AddBuff(BuffID.WaterWalking, 60);
            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 > 10)
                    {
                        npc.timeLeft = 10;
                    }
                    return;
                }
            }
            npc.rotation  = 0f;
            npc.direction = npc.spriteDirection;
            if ((double)player.position.X > (double)npc.position.X)
            {
                npc.spriteDirection = 1;
            }
            else if ((double)player.position.X < (double)npc.position.X)
            {
                npc.spriteDirection = -1;
            }

            if (frameTimer % 10 == 0)
            {
                frame++;
                frameTimer = 0;
            }
            if (frame > 4 && !attackAnim)
            {
                frame = 0;
            }
            if (aiTimer > 160 && aiTimer < 1200)
            {
                if (aiTimer == 161)
                {
                    attackAnim = true;
                    frame      = 5;
                }
                if (aiTimer == 167)
                {
                    frame = 6;
                }
                if (aiTimer == 173)
                {
                    frame = 7;
                }
                if (aiTimer == 179)
                {
                    frame = 8;
                }
                if (aiTimer == 185)
                {
                    frame      = 9;
                    attackAnim = false;
                }
                waterTimer++;
                teleportingTimer++;
                switch (Main.rand.Next(4))
                {
                case 0:
                {
                    if (attackID == -1)
                    {
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                        attackID = 0;
                    }
                }
                break;

                case 1:
                {
                    if (attackID == -1)
                    {
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                        attackID = 1;
                    }
                }
                break;

                case 2:
                {
                    if (attackID == -1)
                    {
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                        attackID = 2;
                    }
                }
                break;

                case 3:
                {
                    if (attackID == -1)
                    {
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                        attackID = 3;
                    }
                }
                break;
                }

                //summons tornados that chase the player & suck him in
                if (attackID == 0)
                {
                    tornadoTimer++;
                    if (tornadoTimer % (Main.expertMode ? 40 : 60) == 0)
                    {
                        Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 8);
                        NPC.NewNPC((int)((Main.player[npc.target].position.X - 500) + Main.rand.Next(1000)), (int)((Main.player[npc.target].position.Y - 500) + Main.rand.Next(1000)), mod.NPCType("SeaTornado"));
                    }
                }

                //curses the air, starts a countdown, in the end deals 1/3 (1/2 in expert) health damage to the player if he's not in the water
                else if (attackID == 1)
                {
                    string CursedAir = Language.GetTextValue("Mods.Antiaris.CursedAir");
                    waterTimer++;
                    if (waterTimer == 50)
                    {
                        Main.NewText(CursedAir, 76, 255, 246);
                    }
                    if (waterTimer < 760 && waterTimer % 120 == 0)
                    {
                        CombatText.NewText(new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height), Color.Cyan, 7 - waterTimer / 120, false, false);
                    }
                    if (waterTimer == 880 && !player.wet)
                    {
                        CombatText.NewText(new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height), Color.Red, player.statLife / 3, false, false);
                        player.statLife -= player.statLife / (Main.expertMode ? 2 : 3);
                    }
                }

                //swaps himself & the player, shoots sharks at the player, in the end returns to the beginning position
                if (attackID == 2)
                {
                    teleportingTimer++;
                    if (teleportingTimer == 120)
                    {
                        positionX = npc.position.X;
                        positionY = npc.position.Y;
                    }
                    if (teleportingTimer % 160 == 0)
                    {
                        bossOldPosX = npc.position.X;
                        bossOldPosY = npc.position.Y;

                        playerOldPosX = player.position.X;
                        playerOldPosY = player.position.Y;
                        Main.PlaySound(SoundID.Item8, npc.position);
                        for (int i = 0; i < 10; i++)
                        {
                            int dust = Dust.NewDust(new Vector2((float)npc.position.X, (float)npc.position.Y), npc.width, npc.height, 56, npc.velocity.X + Main.rand.Next(-10, 10), npc.velocity.Y + Main.rand.Next(-10, 10), 5, npc.color, 2.6f);
                            Main.dust[dust].noGravity = true;
                        }
                        Main.PlaySound(SoundID.Item8, player.position);
                        for (int i = 0; i < 10; i++)
                        {
                            int dust = Dust.NewDust(new Vector2((float)player.position.X, (float)player.position.Y), player.width, player.height, 56, player.velocity.X + Main.rand.Next(-10, 10), player.velocity.Y + Main.rand.Next(-10, 10), 5, Color.LightBlue, 2.6f);
                            Main.dust[dust].noGravity = true;
                        }
                        player.position.X = bossOldPosX;
                        player.position.Y = bossOldPosY;
                        npc.position.X    = playerOldPosX;
                        npc.position.Y    = playerOldPosY;

                        var velocity = AntiarisHelper.VelocityToPoint(npc.Center, AntiarisHelper.RandomPointInArea(new Vector2(player.Center.X - 10, player.Center.Y - 10), new Vector2(player.Center.X + 20, player.Center.Y + 20)), Main.expertMode ? 16 : 20);
                        var shark    = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, 408, Main.rand.Next(20, 30), 1f);
                        Main.projectile[shark].friendly    = false;
                        Main.projectile[shark].hostile     = true;
                        Main.projectile[shark].tileCollide = false;
                        Main.projectile[shark].timeLeft    = 300;
                    }
                }

                //steals player's soul, if the soul gets to Deadly Jones, he damages the player for 1/2 of health & restores his health for same amount
                //stay near soul to return it
                if (attackID == 3)
                {
                    string SoulStolen = Language.GetTextValue("Mods.Antiaris.SoulStolen");
                    soulTimer++;
                    if (soulTimer == 60)
                    {
                        Main.PlaySound(SoundID.Item8, npc.position);
                        CombatText.NewText(new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height), Color.Cyan, SoulStolen, false, false);
                        var velocity = AntiarisHelper.VelocityToPoint(player.Center, AntiarisHelper.RandomPointInArea(new Vector2(npc.Center.X - 10, npc.Center.Y - 10), new Vector2(npc.Center.X + 20, npc.Center.Y + 20)), Main.expertMode ? 1 : 2);
                        var soul     = Projectile.NewProjectile(player.Center.X, player.Center.Y, velocity.X, velocity.Y, mod.ProjectileType("StolenSoul"), 0, 0f, Main.myPlayer);
                    }
                }
            }
            if (aiTimer == 600)
            {
                aiTimer          = 0;
                tornadoTimer     = 0;
                waterTimer       = 0;
                teleportingTimer = 0;
                soulTimer        = 0;
                attackID         = -1;
            }
            if (!player.ZoneBeach)
            {
                string LeavingBeach = Language.GetTextValue("Mods.Antiaris.LeavingBeach");
                Main.NewText(LeavingBeach);
                Main.PlaySound(SoundID.Item8, player.position);
                for (int i = 0; i < 10; i++)
                {
                    int dust = Dust.NewDust(new Vector2((float)player.position.X, (float)player.position.Y), player.width, player.height, 56, player.velocity.X + Main.rand.Next(-10, 10), player.velocity.Y + Main.rand.Next(-10, 10), 5, Color.LightBlue, 2.6f);
                    Main.dust[dust].noGravity = true;
                }
                player.position.X = npc.position.X;
                player.position.Y = npc.position.Y;
            }
        }
コード例 #16
0
        public override void AI()
        {
            Player  player = Main.player[npc.target];
            Vector2 target = npc.HasPlayerTarget ? player.Center : Main.npc[npc.target].Center;

            npc.netAlways = true;
            npc.rotation  = 0.0f;
            npc.TargetClosest(true);
            if (npc.life >= npc.lifeMax)
            {
                npc.life = npc.lifeMax;
            }
            if (npc.target < 0 || npc.target == 255 || player.dead || !player.active)
            {
                npc.TargetClosest(false);
                npc.direction  = 1;
                npc.velocity.Y = npc.velocity.Y - 0.1f;
                if (npc.timeLeft > 10)
                {
                    npc.timeLeft = 10;
                    return;
                }
            }
            if (this.stunned)
            {
                npc.velocity.Y = 0.0f;
                npc.velocity.X = 0.0f;
                ++this.stunnedTimer;
                if (this.stunnedTimer >= 105)
                {
                    this.stunned      = false;
                    this.stunnedTimer = 0;
                }
            }
            if (!this.secondState)
            {
                float distance = 160f;
                float k        = 1.26f;
                for (int count = 0; count < 10; count++)
                {
                    Vector2 spawn = npc.Center + distance * ((float)count * k).ToRotationVector2();
                    NPC.NewNPC((int)spawn.X, (int)spawn.Y, mod.NPCType("ProtectiveStone2"), 0, (float)npc.whoAmI, 0.0f, (float)count, 0.0f, 255);
                }
                this.secondState = true;
            }
            ++this.ai;
            npc.ai[0] = (float)this.ai * 1f;
            int  velocity = (int)((double)npc.ai[0] / 50f);
            bool speedB   = ((double)npc.life <= npc.lifeMax * 0.6 ? true : false);
            int  speedV   = (int)(speedB ? 6f : 0f);

            if ((double)npc.ai[0] < 350.0 && !this.stunned)
            {
                this.frame = 0;
                AntiarisHelper.MoveTowards(npc, target, (int)(Vector2.Distance(target, npc.Center) > 300 ? (Main.expertMode ? 24f : 20f) : (Main.expertMode ? 9f : 7f)) + speedV, 30f);
                for (int k = 0; k < 5 * (npc.ai[0] / 50); k++)
                {
                    float scale = 0.4f;
                    if (npc.ai[0] % 2 == 1)
                    {
                        scale = 0.65f;
                    }
                    Vector2 sDust  = npc.Center + ((float)Main.rand.NextDouble() * 6.283185f).ToRotationVector2() * (12f - (float)(velocity * 2));
                    int     index2 = Dust.NewDust(sDust - Vector2.One * 12f, 24, 24, 62, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, new Color(), 1f);
                    Main.dust[index2].position  -= new Vector2(2f);
                    Main.dust[index2].velocity   = Vector2.Normalize(npc.Center - sDust) * 1.5f * (float)(10.0 - (double)velocity * 2.0) / 10f;
                    Main.dust[index2].noGravity  = true;
                    Main.dust[index2].scale      = scale;
                    Main.dust[index2].customData = (object)npc;
                }
                npc.netUpdate = true;
                if ((double)npc.ai[0] % 349.0 == 0)
                {
                    this.buffTime += 1;
                    //CombatText.NewText(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), Color.Purple, "+1", false, false);
                }
            }
            else if ((double)npc.ai[0] >= 350.0 && (double)npc.ai[0] < 450.0)
            {
                this.stunned = true;
                this.frame   = 2;
                AntiarisHelper.MoveTowards(npc, target, (int)(Vector2.Distance(target, npc.Center) > 300 ? (Main.expertMode ? 24f : 20f) : (Main.expertMode ? 9f : 7f)) + speedV, 30f);
                for (int k = 0; k < 2 * (npc.ai[0] / 45); k++)
                {
                    float scale = 0.65f;
                    if (npc.ai[0] % 2 == 1)
                    {
                        scale = 0.81f;
                    }
                    Vector2 sDust  = npc.Center + ((float)Main.rand.NextDouble() * 6.283185f).ToRotationVector2() * (12f - (float)(velocity * 2));
                    int     index2 = Dust.NewDust(sDust - Vector2.One * 12f, 24, 24, 62, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, new Color(), 1f);
                    Main.dust[index2].position  -= new Vector2(2f);
                    Main.dust[index2].velocity   = Vector2.Normalize(npc.Center - sDust) * 1.5f * (float)(10.0 - (double)velocity * 2.0) / 10f;
                    Main.dust[index2].noGravity  = true;
                    Main.dust[index2].scale      = scale;
                    Main.dust[index2].customData = (object)npc;
                }
                player.AddBuff(mod.BuffType("Injured"), Main.expertMode ? 560 : 420, true);
                npc.netUpdate = true;
            }
            if ((double)npc.ai[0] > 450.0)
            {
                this.frame   = 1;
                this.stunned = false;
                npc.defense  = 40;
                if (!this.fastSpeed)
                {
                    if (Main.rand.Next(2) == 0)
                    {
                        this.fastSpeed = true;
                        npc.ai[2]      = 0f;
                    }
                    else
                    {
                        this.fastSpeed = true;
                        npc.ai[2]      = 1f;
                    }
                }
                else
                {
                    if ((double)npc.ai[2] == 0.0)
                    {
                        if ((double)npc.ai[0] % 50 == 0)
                        {
                            float speed = 21f + speedV;
                            if (Main.expertMode)
                            {
                                speed = 25f + speedV;
                            }
                            Vector2 vector_      = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                            float   x            = player.position.X + (float)(player.width / 2) - vector_.X;
                            float   y            = player.position.Y + (float)(player.height / 2) - vector_.Y;
                            float   distanse     = (float)Math.Sqrt((double)x * (double)x + (double)y * (double)y);
                            float   resuceFactor = speed / distanse;
                            npc.velocity.X = x * resuceFactor;
                            npc.velocity.Y = y * resuceFactor;
                        }
                    }
                    else
                    {
                        npc.alpha = 180;
                        if ((double)npc.ai[0] % 35 == 0)
                        {
                            float speed = 28f + speedV;
                            if (Main.expertMode)
                            {
                                speed = 30f + speedV;
                            }
                            Vector2 vector_      = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                            float   x            = player.position.X + (float)(player.width / 2) - vector_.X;
                            float   y            = player.position.Y + (float)(player.height / 2) - vector_.Y;
                            float   distanse     = (float)Math.Sqrt((double)x * (double)x + (double)y * (double)y);
                            float   resuceFactor = speed / distanse;
                            npc.velocity.X = x * resuceFactor;
                            npc.velocity.Y = y * resuceFactor;
                        }
                    }
                }
                npc.netUpdate = true;
            }
            else
            {
                npc.defense = 22;
            }
            if ((double)npc.ai[0] >= 650.0)
            {
                this.ai        = 0;
                npc.alpha      = 0;
                npc.ai[2]      = 0;
                this.fastSpeed = false;
            }
            if ((double)npc.life <= npc.lifeMax * 0.333)
            {
                npc.alpha   = 0;
                this.ai     = 0;
                this.frame  = 0;
                npc.ai[1]  += 1 + ((double)npc.life <= npc.lifeMax * 0.111 ? 1 : ((double)npc.life <= npc.lifeMax * 0.222 ? 1 : 0));
                npc.defense = 25;
                if ((double)npc.ai[1] < 200.0)
                {
                    this.frame     = 2;
                    npc.velocity.X = 0f; npc.velocity.Y = 0f;
                }
                if ((double)npc.ai[1] < 200.0)
                {
                    for (int k = 0; k < 3 * (npc.ai[1] / 50); k++)
                    {
                        float scale = 0.81f;
                        if (npc.ai[0] % 2 == 1)
                        {
                            scale = 1f;
                        }
                        Vector2 sDust  = npc.Center + ((float)Main.rand.NextDouble() * 6.283185f).ToRotationVector2() * (12f - (float)(velocity * 2));
                        int     index2 = Dust.NewDust(sDust - Vector2.One * 12f, 24, 24, 62, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, new Color(), 1f);
                        Main.dust[index2].position  -= new Vector2(2f);
                        Main.dust[index2].velocity   = Vector2.Normalize(npc.Center - sDust) * 1.5f * (float)(10.0 - (double)velocity * 2.0) / 10f;
                        Main.dust[index2].noGravity  = true;
                        Main.dust[index2].scale      = scale;
                        Main.dust[index2].customData = (object)npc;
                    }
                }
                if ((double)npc.ai[1] % 200.0 == 0 && (double)npc.ai[1] <= 399.0)
                {
                    this.attackTimer += 1;
                    if (this.attackTimer <= 2)
                    {
                        Vector2 shootPos   = npc.Center;
                        float   inaccuracy = 10f * (npc.life / npc.lifeMax);
                        Vector2 shootVel   = target - shootPos + new Vector2(Main.rand.NextFloat(-inaccuracy, inaccuracy), Main.rand.NextFloat(-inaccuracy, inaccuracy));
                        shootVel.Normalize();
                        shootVel *= 14f;
                        Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 88);
                        for (int k = 0; k < (Main.expertMode ? 5 : 3); k++)
                        {
                            Projectile.NewProjectile(shootPos.X + (float)(-100 * npc.direction) + (float)Main.rand.Next(-40, 41), shootPos.Y - (float)Main.rand.Next(-50, 40), shootVel.X, shootVel.Y, mod.ProjectileType("GolemCrystal2"), npc.damage / 3, 5f);
                        }
                    }
                    else
                    {
                        if (Main.expertMode)
                        {
                            for (int i = 0; i < 7; i++)
                            {
                                Projectile.NewProjectile((int)((player.position.X - 50) + Main.rand.Next(100)), (int)((player.position.Y - 50) + Main.rand.Next(100)), 0.0f, 0.0f, mod.ProjectileType("TowerKeeper2Sheet"), npc.damage / 3, 4.5f);
                            }
                        }
                        for (int k = 0; k < (Main.expertMode ? 8 : 5); k++)
                        {
                            Vector2 shootPos = player.position + new Vector2(Main.rand.Next(-300, 300), -1000);
                            Vector2 shootVel = new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(9f, 14f));
                            Projectile.NewProjectile(shootPos, shootVel, mod.ProjectileType("GolemCrystal2"), npc.damage / 2, 4.5f);
                        }
                        Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 88);
                        this.attackTimer = 0;
                    }
                }
                if ((double)npc.ai[1] > 200.0)
                {
                    AntiarisHelper.MoveTowards(npc, player.Center, 8f + (float)((double)npc.life <= npc.lifeMax * 0.111 ? 3 : ((double)npc.life <= npc.lifeMax * 0.222 ? 2 : 0)), 8f + (float)((double)npc.life <= npc.lifeMax * 0.111 ? 3 : ((double)npc.life <= npc.lifeMax * 0.222 ? 2 : 0)));
                }
                if (npc.ai[1] >= 350f)
                {
                    npc.ai[1] = 0f;
                }
                npc.netUpdate = true;
            }
            if ((double)npc.life <= npc.lifeMax * 0.135)
            {
                this.frame   = 1;
                this.stunned = true;
                if (!this.secondState2)
                {
                    float distance = 160f;
                    float k        = 1.26f;
                    for (int count = 0; count < 10; count++)
                    {
                        Vector2 spawn = npc.Center + distance * ((float)count * k).ToRotationVector2();
                        NPC.NewNPC((int)spawn.X, (int)spawn.Y, mod.NPCType("ProtectiveStone2"), 0, (float)npc.whoAmI, 0.0f, (float)count, 0.0f, 255);
                    }
                    this.secondState2 = true;
                }
                if (NPC.AnyNPCs(mod.NPCType("ProtectiveStone2")))
                {
                    //if ((double)this.ai % 215.0 == 0.0)
                    if (Main.rand.Next(5) == 0)
                    {
                        Projectile.NewProjectile((int)((npc.position.X - 500) + Main.rand.Next(1000)), (int)((npc.position.Y - 500) + Main.rand.Next(1000)), 0.0f, 0.0f, mod.ProjectileType("TowerKeeper2Sheet"), npc.damage / 3, 4.5f);
                    }
                    npc.dontTakeDamage = true;
                }
                else
                {
                    //if ((double)this.ai % 225.0 == 0.0)
                    if (Main.rand.Next(5) == 0)
                    {
                        Projectile.NewProjectile((int)((npc.position.X - 500) + Main.rand.Next(1000)), (int)((npc.position.Y - 500) + Main.rand.Next(1000)), 0.0f, 0.0f, mod.ProjectileType("TowerKeeper2Sheet"), npc.damage / 3, 4.5f);
                    }
                    npc.dontTakeDamage = false;
                }
            }
            if (this.buffTime >= 3)
            {
                ++this.buffTimeKey;
                if (this.buffTimeKey >= 120)
                {
                    player.AddBuff(BuffID.BrokenArmor, Main.expertMode ? 320 : 60, true);
                    player.AddBuff(BuffID.Slow, Main.expertMode ? 320 : 60, true);
                    Main.player[Main.myPlayer].statMana = 0;
                    this.buffTime    = 0;
                    this.buffTimeKey = 0;
                    npc.netUpdate    = true;
                }
            }
            if (this.checkDead)
            {
                npc.dontTakeDamage = true;
                this.ai            = 0;
                npc.ai[0]          = 0;
                npc.ai[1]          = 0;
                npc.velocity.X     = npc.velocity.Y = 0f;
                ++this.deadTimer;
                this.frame = 0;
                for (int k = 0; k < 5 * (this.deadTimer / 50); k++)
                {
                    npc.dontTakeDamage = true;
                    float scale = 0.81f;
                    if (npc.ai[0] % 2 == 1)
                    {
                        scale = 1f;
                    }
                    Vector2 sDust  = npc.Center + ((float)Main.rand.NextDouble() * 6.283185f).ToRotationVector2() * (12f - (float)(velocity * 2));
                    int     index2 = Dust.NewDust(sDust - Vector2.One * 12f, 24, 24, 62, npc.velocity.X / 2f, npc.velocity.Y / 2f, 0, new Color(), 1f);
                    Main.dust[index2].position  -= new Vector2(2f);
                    Main.dust[index2].velocity   = Vector2.Normalize(npc.Center - sDust) * 1.5f * (float)(10.0 - (double)velocity * 2.0) / 10f;
                    Main.dust[index2].noGravity  = true;
                    Main.dust[index2].scale      = scale;
                    Main.dust[index2].customData = (object)npc;
                }
                if (this.deadTimer == 100)
                {
                    Main.PlaySound(mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/NPCs/TowerKeeperDeath"), npc.position);
                }
                if (this.deadTimer >= 300)
                {
                    this.frame = 1;
                    if (this.deadTimer >= 400)
                    {
                        npc.life = 0;
                        npc.HitEffect(0, 1337);
                        npc.checkDead();
                        Main.PlaySound(4, (int)npc.position.X, (int)npc.position.Y, 43);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore1"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore2"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore2"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore2"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore3"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore3"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore3"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore4"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore4"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore4"), 1f);
                        Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/TowerKeeperGore4"), 1f);
                    }
                }
                if (this.deadTimer >= 0)
                {
                    Main.musicFade[Main.curMusic] = 1f / (float)(this.deadTimer / 15 * 0.5f);
                }
            }
        }
コード例 #17
0
ファイル: AntlionQueen.cs プロジェクト: zadum4ivii/Antiaris
        public override void AI()
        {
            Player  player = Main.player[npc.target];
            Vector2 target = npc.HasPlayerTarget ? player.Center : Main.npc[npc.target].Center;

            npc.netAlways = true;
            npc.TargetClosest(true);
            npc.rotation   = npc.velocity.X * 0.045f;
            this.moveSpeed = (int)((float)((double)npc.lifeMax / (double)npc.life) * 0.05f);
            if ((double)player.position.X >= (double)npc.position.X - 8.0)
            {
                npc.spriteDirection = 1;
            }
            else if ((double)player.position.X < (double)npc.position.X - 8.0)
            {
                npc.spriteDirection = -1;
            }
            if (((!Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) && npc.justHit) || npc.velocity.Y == 0f)
            {
                if ((npc.collideY) || (npc.collideX))
                {
                    npc.noTileCollide = true;
                }
                else if ((Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)))
                {
                    npc.noTileCollide = false;
                }
            }
            if (npc.target < 0 || npc.target == 255 || player.dead || !player.active)
            {
                npc.TargetClosest(false);
                npc.direction = 1;
                if (npc.velocity.X > 0f)
                {
                    npc.velocity.X = npc.velocity.X + 0.75f;
                }
                else
                {
                    npc.velocity.X = npc.velocity.X - 0.75f;
                }
                npc.velocity.Y = npc.velocity.Y - 0.1f;
                if (npc.timeLeft > 10)
                {
                    npc.timeLeft = 10;
                    return;
                }
            }
            if (!player.ZoneDesert)
            {
                AntiarisHelper.MoveTowards(npc, player.Center, 75f, 75f);
            }
            if (this.stunned)
            {
                npc.velocity.Y = 0.0f;
                npc.velocity.X = 0.0f;
                ++this.stunnedTimer;
                if (this.stunnedTimer >= 105)
                {
                    this.stunned      = false;
                    this.stunnedTimer = 0;
                }
            }
            if (this.end)
            {
                this.mv      = 0;
                this.ai      = 0;
                npc.ai[0]    = 0f;
                npc.ai[1]    = 0f;
                npc.ai[2]    = 0f;
                npc.ai[3]    = 0f;
                this.sAI     = false;
                this.stunned = false;
                this.end     = false;
            }
            if (player.ZoneDesert && !player.ZoneBeach)
            {
                this.StartSandstorm();
            }
            ++this.ai;
            if ((double)npc.ai[0] < 150.0 && !this.stunned && !this.sAI)
            {
                npc.ai[0]  = (float)this.ai * 1f;
                this.frame = 0;
                AntiarisHelper.MoveTowards(npc, target - new Vector2(0f, 250f), this.rage ? 40f : 30f, 30f);
                npc.ai[1] += 1f;
                if (npc.ai[1] % (float)(Main.expertMode ? 25 : 30) == 0)
                {
                    int y    = (int)(npc.Center.Y / 16f);
                    int x    = (int)(npc.Center.X / 16f);
                    int size = 100;
                    if (x < 10)
                    {
                        x = 10;
                    }
                    if (x > Main.maxTilesX - 10)
                    {
                        x = Main.maxTilesX - 10;
                    }
                    if (y < 10)
                    {
                        y = 10;
                    }
                    if (y > Main.maxTilesY - size - 10)
                    {
                        y = Main.maxTilesY - size - 10;
                    }
                    for (int finPos = y; finPos < y + size; finPos++)
                    {
                        Tile tile = Main.tile[x, finPos];
                        if (tile.active() && (Main.tileSolid[(int)tile.type] || tile.liquid != 0))
                        {
                            y = finPos;
                            break;
                        }
                    }
                    Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 - 56), 0f, 0f, mod.ProjectileType("Sandnado"), npc.damage / 2, 0f, Main.myPlayer, 16f, 15f);
                }
                npc.netUpdate = true;
            }
            else if ((double)npc.ai[0] >= 145.0 && !this.stunned && !this.sAI)
            {
                npc.noTileCollide = false;
                npc.velocity.X    = 0f;
                npc.velocity.Y    = 5f;
                this.frame        = 1;
                npc.netUpdate     = true;
                ++this.swarmerSpawnTimer;
                ++npc.ai[2];
                if ((double)npc.ai[2] > 60.0 && this.swarmerSpawnTimer > 60)
                {
                    Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                    NPC.NewNPC((int)(player.Center.X + 1200f), (int)(player.Center.Y - 1000f), 509, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                    if ((double)(npc.lifeMax - npc.life) > (double)(40.0 * 100f))
                    {
                        NPC.NewNPC((int)(player.Center.X - 1200f), (int)(player.Center.Y - 1000f), 508, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                    }
                    this.swarmerSpawnTimer -= (Main.expertMode ? 30 : 60);
                }
                if ((double)npc.ai[2] > 120.0)
                {
                    this.swarmerSpawnTimer = 0;
                    this.sAI  = true;
                    npc.ai[3] = 10f;
                }
                npc.netUpdate = true;
            }
            if ((double)npc.ai[3] >= 10.0 && (double)npc.ai[3] < 20.0)
            {
                this.mv          += 1 + (int)((npc.life > npc.lifeMax / 2 ? 0 : 1) + (npc.life > npc.lifeMax / 3 ? 0 : 1));
                this.frame        = 0;
                npc.noTileCollide = true;
                if (this.mv >= 150 && this.mv < 500)
                {
                    Vector2 vector2_1 = player.Center + new Vector2(0.0f, -600.0f);
                    float   speed     = 7f;
                    Vector2 vector2_2 = vector2_1 - npc.Center;
                    float   distance  = (float)Math.Sqrt((double)vector2_2.X * (double)vector2_2.X + (double)vector2_2.Y * (double)vector2_2.Y);
                    vector2_2   *= speed / distance;
                    npc.velocity = vector2_2;
                    if (this.mv > 350)
                    {
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                        npc.velocity.X = 0.0f;
                        npc.velocity.Y = 20f;
                        if ((double)npc.position.Y < (double)player.position.Y + 500.0)
                        {
                            this.mv = 425;
                        }
                    }
                    if (this.mv >= 425)
                    {
                        AntiarisHelper.MoveTowards(npc, target - new Vector2(0f, 25f), (npc.life <= npc.lifeMax * 0.35f) ? 435f : 275f, 30f);
                    }
                }
                else if (this.mv >= 650 && this.mv < 1000)
                {
                    Vector2 vector2_1 = player.Center + new Vector2(-600.0f, 0.0f);
                    float   speed     = 7f;
                    Vector2 vector2_2 = vector2_1 - npc.Center;
                    float   distance  = (float)Math.Sqrt((double)vector2_2.X * (double)vector2_2.X + (double)vector2_2.Y * (double)vector2_2.Y);
                    vector2_2   *= speed / distance;
                    npc.velocity = vector2_2;
                    if (this.mv > 850)
                    {
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                        npc.velocity.X = 20f;
                        npc.velocity.Y = 0.0f;
                        if ((double)npc.position.X < (double)player.position.X + 500.0)
                        {
                            this.mv = 925;
                        }
                    }
                    if (this.mv >= 925)
                    {
                        AntiarisHelper.MoveTowards(npc, target - new Vector2(0f, 25f), (npc.life <= npc.lifeMax * 0.35f) ? 435f : 275f, 30f);
                    }
                }
                else if (this.mv >= 1150 && this.mv < 1500)
                {
                    Vector2 vector2_1 = player.Center + new Vector2(600.0f, 0.0f);
                    float   speed     = 7f;
                    Vector2 vector2_2 = vector2_1 - npc.Center;
                    float   distance  = (float)Math.Sqrt((double)vector2_2.X * (double)vector2_2.X + (double)vector2_2.Y * (double)vector2_2.Y);
                    vector2_2   *= speed / distance;
                    npc.velocity = vector2_2;
                    if (this.mv > 1350)
                    {
                        Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                        npc.velocity.X = -20f;
                        npc.velocity.Y = 0.0f;
                        if ((double)npc.position.X > (double)player.position.X - 500.0)
                        {
                            this.mv = 1425;
                        }
                    }
                    if (this.mv >= 1425)
                    {
                        AntiarisHelper.MoveTowards(npc, target - new Vector2(0f, 25f), (npc.life <= npc.lifeMax * 0.35f) ? 435f : 275f, 30f);
                    }
                }
                else
                {
                    AntiarisHelper.MoveTowards(npc, target, Vector2.Distance(target, npc.Center) > 500 ? (Main.expertMode ? 32f : 30f) : (Main.expertMode ? 13f : 11f), 30f);
                }
                if (this.mv >= 1600)
                {
                    this.mv   = 0;
                    npc.ai[3] = 20f;
                }
                npc.netUpdate = true;
            }
            else if ((double)npc.ai[3] >= 20.0 && (double)npc.ai[3] < 30.0)
            {
                AntiarisHelper.MoveTowards(npc, target, Vector2.Distance(target, npc.Center) > 500 ? (Main.expertMode ? 32f : 30f) : (Main.expertMode ? 13f : 11f), 30f);
                this.mv   += (int)0.2 + (int)((npc.life > npc.lifeMax / 2 ? 0 : 1) + (npc.life > npc.lifeMax / 3 ? 0 : 1));
                this.frame = 0;
                if (this.mv >= 100 && this.mv < 175)
                {
                    if (this.mv % 10 == 0)
                    {
                        Vector2 shootPos   = (npc.Top + new Vector2((npc.direction == -1 ? -150f : 150f), 155f)).RotatedBy(npc.rotation, npc.Center);
                        float   inaccuracy = 3f * (npc.life / npc.lifeMax);
                        Vector2 shootVel   = target - shootPos + new Vector2(Main.rand.NextFloat(-inaccuracy, inaccuracy), Main.rand.NextFloat(-inaccuracy, inaccuracy));
                        shootVel.Normalize();
                        shootVel *= 28f;
                        int k = Projectile.NewProjectile(shootPos, shootVel, 31, npc.damage / 2, 5f, Main.myPlayer);
                        Main.projectile[k].friendly = false;
                        Main.projectile[k].hostile  = true;
                        Main.projectile[k].scale    = 1.4f;
                    }
                }
                else if (this.mv >= 175)
                {
                    this.mv   = 0;
                    npc.ai[3] = 30f;
                }
                npc.netUpdate = true;
            }
            else if ((double)npc.ai[3] >= 30.0)
            {
                this.mv   += 2 + (int)((npc.life > npc.lifeMax / 2 ? 0 : 1) + (npc.life > npc.lifeMax / 3 ? 0 : 1));
                this.frame = 0;
                if (this.mv % 500 == 0)
                {
                    Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                    NPC.NewNPC((int)(player.Center.X - 1200f), (int)(player.Center.Y - 1000f), 508, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                    NPC.NewNPC((int)(player.Center.X + 1200f), (int)(player.Center.Y - 1000f), 508, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                }
                if (this.mv >= 650 && this.mv < 800)
                {
                    if (this.mv >= 650 && this.mv < 725)
                    {
                        if (player.position.Y < npc.position.Y + 650)
                        {
                            npc.velocity.Y -= 0.44f;
                        }
                    }
                    if (player.position.Y >= npc.position.Y + 650)
                    {
                        Vector2 targetPos   = player.Center;
                        float   speed       = 15f;
                        float   speedFactor = 0.7f;
                        Vector2 center      = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                        float   posX        = targetPos.X - center.X;
                        float   posY        = targetPos.Y - center.Y;
                        float   distance    = (float)Math.Sqrt((double)(posX * posX + posY * posY));
                        distance = speed / distance;
                        posX    *= distance;
                        posY    *= distance;
                        if (npc.velocity.X < posX)
                        {
                            npc.velocity.X = npc.velocity.X + speedFactor;
                            if (npc.velocity.X < 0f && posX > 0f)
                            {
                                npc.velocity.X = npc.velocity.X + speedFactor;
                            }
                        }
                        else if (npc.velocity.X > posX)
                        {
                            npc.velocity.X = npc.velocity.X - speedFactor;
                            if (npc.velocity.X > 0f && posX < 0f)
                            {
                                npc.velocity.X = npc.velocity.X - speedFactor;
                            }
                        }
                        if (npc.velocity.Y < posY)
                        {
                            npc.velocity.Y = npc.velocity.Y + speedFactor;
                            if (npc.velocity.Y < 0f && posY > 0f)
                            {
                                npc.velocity.Y = npc.velocity.Y + speedFactor;
                            }
                        }
                        else if (npc.velocity.Y > posY)
                        {
                            npc.velocity.Y = npc.velocity.Y - speedFactor;
                            if (npc.velocity.Y > 0f && posY < 0f)
                            {
                                npc.velocity.Y = npc.velocity.Y - speedFactor;
                            }
                        }
                        this.mv = 720;
                    }
                }
                else if (this.mv >= 1000 && this.mv < 1150)
                {
                    if (this.mv >= 1000 && this.mv < 1075)
                    {
                        if (player.position.Y < npc.position.Y + 650)
                        {
                            npc.velocity.Y -= 0.44f;
                        }
                    }
                    if (player.position.Y >= npc.position.Y + 650)
                    {
                        Vector2 targetPos   = player.Center;
                        float   speed       = 15f;
                        float   speedFactor = 0.7f;
                        Vector2 center      = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                        float   posX        = targetPos.X - center.X;
                        float   posY        = targetPos.Y - center.Y;
                        float   distance    = (float)Math.Sqrt((double)(posX * posX + posY * posY));
                        distance = speed / distance;
                        posX    *= distance;
                        posY    *= distance;
                        if (npc.velocity.X < posX)
                        {
                            npc.velocity.X = npc.velocity.X + speedFactor;
                            if (npc.velocity.X < 0f && posX > 0f)
                            {
                                npc.velocity.X = npc.velocity.X + speedFactor;
                            }
                        }
                        else if (npc.velocity.X > posX)
                        {
                            npc.velocity.X = npc.velocity.X - speedFactor;
                            if (npc.velocity.X > 0f && posX < 0f)
                            {
                                npc.velocity.X = npc.velocity.X - speedFactor;
                            }
                        }
                        if (npc.velocity.Y < posY)
                        {
                            npc.velocity.Y = npc.velocity.Y + speedFactor;
                            if (npc.velocity.Y < 0f && posY > 0f)
                            {
                                npc.velocity.Y = npc.velocity.Y + speedFactor;
                            }
                        }
                        else if (npc.velocity.Y > posY)
                        {
                            npc.velocity.Y = npc.velocity.Y - speedFactor;
                            if (npc.velocity.Y > 0f && posY < 0f)
                            {
                                npc.velocity.Y = npc.velocity.Y - speedFactor;
                            }
                        }
                        this.mv = 1070;
                    }
                }
                else
                {
                    AntiarisHelper.MoveTowards(npc, target, Vector2.Distance(target, npc.Center) > 500 ? (Main.expertMode ? 32f : 30f) : (Main.expertMode ? 13f : 11f), 30f);
                }
                if (this.mv >= 1150)
                {
                    this.end = true;
                }
                npc.netUpdate = true;
            }
            if (npc.life <= npc.lifeMax * 0.35f)
            {
                this.rage = true;
            }
            if (npc.life <= npc.lifeMax * 0.15f)
            {
                this.end          = true;
                this.frame        = 0;
                this.stunned      = true;
                npc.noTileCollide = false;
                Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 0);
                ++this.aiSECOND;
                if (this.aiSECOND % 2 == 0 && this.aiSECOND <= 120)
                {
                    var ShootPos = player.position + new Vector2(Main.rand.Next(-1000, 1000), -1000);
                    var ShootVel = new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(15f, 20f));
                    var k        = Projectile.NewProjectile(ShootPos, ShootVel, 31, npc.damage / 4, 1f);
                    Main.projectile[k].friendly    = false;
                    Main.projectile[k].hostile     = true;
                    Main.projectile[k].scale       = 1.4f;
                    Main.projectile[k].tileCollide = false;
                }
                if (this.aiSECOND >= 250 && this.aiSECOND < 320 && this.aiSECOND % 15 == 0)
                {
                    var shootPos   = (npc.Top + new Vector2((npc.direction == -1 ? -150f : 150f), 155f)).RotatedBy(npc.rotation, npc.Center);
                    var inaccuracy = 3f * (npc.life / npc.lifeMax);
                    var shootVel   = target - shootPos + new Vector2(Main.rand.NextFloat(-inaccuracy, inaccuracy), Main.rand.NextFloat(-inaccuracy, inaccuracy));
                    shootVel.Normalize();
                    shootVel *= 28f;
                    var k = Projectile.NewProjectile(shootPos, shootVel, 31, npc.damage / 2, 5f, Main.myPlayer);
                    Main.projectile[k].friendly = false;
                    Main.projectile[k].hostile  = true;
                    Main.projectile[k].scale    = 1.4f;
                }
                if (this.aiSECOND >= 450)
                {
                    this.aiSECOND = 0;
                }
                if (Main.expertMode)
                {
                    if (this.aiSECOND % 250 == 0)
                    {
                        NPC.NewNPC((int)(player.Center.X - 1200f), (int)(player.Center.Y - 1000f), 508, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                        NPC.NewNPC((int)(player.Center.X - 1200f), (int)(player.Center.Y - 1000f), 509, 0, (float)npc.whoAmI, 0.0f, 0.0f, 0.0f, (int)byte.MaxValue);
                    }
                }
            }
        }
コード例 #18
0
 public override void Kill(int timeLeft)
 {
     Microsoft.Xna.Framework.Vector2 velocity = AntiarisHelper.VelocityToPoint(projectile.Center, Main.MouseWorld, 4);
     Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, velocity.X, velocity.Y, ModContent.ProjectileType <CelestialMagic>(), projectile.damage, projectile.knockBack * 0.5f, projectile.owner);
 }
コード例 #19
0
        public override void Kill(int timeLeft)
        {
            var velocity = AntiarisHelper.VelocityToPoint(projectile.Center, Main.MouseWorld, 4);

            Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, velocity.X, velocity.Y, mod.ProjectileType("CelestialMagic"), projectile.damage, projectile.knockBack * 0.5f, projectile.owner);
        }
コード例 #20
0
        public override void AI()
        {
            npc.TargetClosest(true);
            var player = Main.player[npc.target];

            npc.netUpdate       = true;
            npc.spriteDirection = npc.direction;
            npc.rotation        = npc.velocity.X * 0.1f;
            if (npc.target < 0 || npc.target == 255 || player.dead || !player.active)
            {
                npc.TargetClosest(false);
                if (npc.velocity.X > 0.0f)
                {
                    npc.velocity.X = npc.velocity.X + 0.75f;
                }
                else
                {
                    npc.velocity.X = npc.velocity.X - 0.75f;
                }
                npc.velocity.Y = npc.velocity.Y - 0.1f;
                if (npc.timeLeft > 10)
                {
                    npc.timeLeft = 10;
                    return;
                }
            }
            if (Main.rand.Next(700) == 0)
            {
                Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, Main.rand.Next(81, 84));
            }
            var velocity = AntiarisHelper.VelocityToPoint(npc.Center, AntiarisHelper.RandomPointInArea(new Vector2(player.Center.X - 10, player.Center.Y - 10), new Vector2(player.Center.X + 20, player.Center.Y + 20)), 6);

            if (!player.active || player.dead)
            {
                npc.TargetClosest(false);
                npc.velocity.Y = -10;
                timer          = 0;
            }
            ++timer;
            if (timer < 350)
            {
                timer2++;
                if (timer2 >= 10)
                {
                    frame++;
                    timer2 = 0;
                }
                if (frame >= 5)
                {
                    frame = 1;
                }
            }
            if (timer >= 150 && timer < 350)
            {
                Vector2 vector2_1 = player.Center + new Vector2(0.0f, -200.0f);
                float   speed     = 3f;
                Vector2 vector2_2 = vector2_1 - npc.Center;
                float   distance  = (float)Math.Sqrt((double)vector2_2.X * (double)vector2_2.X + (double)vector2_2.Y * (double)vector2_2.Y);
                vector2_2   *= speed / distance;
                npc.velocity = vector2_2;
                if (timer > 250)
                {
                    npc.velocity.X = 0.0f;
                    npc.velocity.Y = 13f;
                    if ((double)npc.position.Y < (double)player.position.Y + 150.0)
                    {
                        timer = 350;
                        frame = 5;
                    }
                }
            }
            else if (timer >= 350)
            {
                npc.velocity.X = 0f;
                npc.velocity.Y = 0f;
                timer3++;
                if (timer3 >= 22)
                {
                    frame++;
                    timer3 = 0;
                }
                if (frame >= 11)
                {
                    frame = 5;
                }
                if (timer % 100 == 0 && Main.netMode != 1)
                {
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, mod.ProjectileType("LeafMagic"), npc.damage, 1f);
                }
            }
            if (timer >= 550)
            {
                timer = 0;
            }
        }