Exemple #1
0
        public override void AI()
        {
            //Die if parent dies or despawns
            if (!Parent.active || Parent.life <= 0)
            {
                projectile.active = false;
            }

            //Evenly spread out the rotations of all 3 runes
            if (!initialized)
            {
                rotation             = RuneNumber * MathHelper.TwoPi / 3;
                projectile.netUpdate = true;
                initialized          = true;
            }

            projectile.alpha = Math.Max(projectile.alpha - 5, 0);
            rotation        += speed;
            speed            = Math.Min(speed + ACCELERATION, MAX_SPEED);

            //Start decreasing in radius when speed is high enough
            if (speed > MAX_SPEED / 4)
            {
                radius -= 1.5f;
                if (radius <= MIN_RADIUS)
                {
                    //Dont shoot a projectile if the target no longer exists
                    bool playerUntargettable = (Target == null || Target.dead || !Target.active);

                    //Only make one projectile shot directly at the player, by checking if it's the first rune that was spawned in
                    if (RuneNumber == 0 && !playerUntargettable)
                    {
                        Projectile p = Projectile.NewProjectileDirect(Parent.Center, Vector2.Zero, ModContent.ProjectileType <HecateBoonProj>(),
                                                                      NPCUtils.ToActualDamage(Parent.damage), 1, Main.myPlayer, Parent.target);

                        if (!Main.dedServ)
                        {
                            Main.PlaySound(SoundID.MaxMana, Parent.Center);
                            ParticleHandler.SpawnParticle(new HecateSpawnParticle(p, new Color(255, 106, 250), 0.5f, 40));
                        }
                    }

                    projectile.Kill();
                }
            }

            Vector2 offset = Vector2.UnitX.RotatedBy(rotation) * radius;

            projectile.Center = Parent.Center + offset;
        }
        private void SoulsP1(Player Target)
        {
            npc.TargetClosest(true);

            if (AiTimer <= 30)
            {
                UpdateYFrame(8, 4, 8);
                if (AiTimer % 15 == 0)
                {
                    Vector2 vel = npc.DirectionFrom(Target.Center).RotatedByRandom(MathHelper.PiOver2) * 14;
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectileDirect(npc.Center + vel, vel.RotatedByRandom(MathHelper.Pi / 12), ModContent.ProjectileType <OccultistSoul>(), NPCUtils.ToActualDamage(30, 1.5f), 1, Main.myPlayer, Main.rand.NextBool() ? -1 : 1, Target.whoAmI).netUpdate = true;
                    }

                    if (!Main.dedServ)
                    {
                        ParticleHandler.SpawnParticle(new PulseCircle(npc.Center, new Color(252, 3, 148) * 0.6f, 120, 15)
                        {
                            RingColor = new Color(255, 115, 239) * 0.4f
                        });
                        ParticleHandler.SpawnParticle(new StarParticle(npc.Center + vel, vel / 8, Color.Lerp(Color.Red, Color.White, 0.15f), 0.5f, 20, 4f));
                        for (int i = 0; i < 4; i++)
                        {
                            ParticleHandler.SpawnParticle(new OccultistSoulVisual(npc.Center + vel * Main.rand.NextFloat(), vel.RotatedByRandom(MathHelper.Pi / 12) * Main.rand.NextFloat(0.2f, 0.7f),
                                                                                  Main.rand.NextFloat(0.4f, 0.5f), 30));
                        }
                    }
                }
            }
            else
            {
                UpdateYFrame(8, 8, 0, null, 0);
            }

            ResetAttackP1(150);
        }
 public override void ModifyHitPvp(Player target, ref int damage, ref bool crit) => damage = NPCUtils.ToActualDamage(damage);
        public override void AI()
        {
            Player player     = Main.player[npc.target];
            bool   expertMode = Main.expertMode;

            Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0f, 0.075f, 0.25f);
            int parent = NPC.FindFirstNPC(ModContent.NPCType <SteamRaiderHead>());

            if (parent < 0 || parent >= Main.npc.Length)
            {
                npc.active = false;
                return;
            }
            if (!Main.npc[(int)npc.ai[1]].active)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
            }
            if (Main.npc[parent].ai[2] != 1)
            {
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    npc.localAI[0] += expertMode ? 2f : 1f;
                    if (npc.localAI[0] >= 200f)
                    {
                        npc.localAI[0] = 0f;
                        npc.TargetClosest(true);
                        if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height))
                        {
                            Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 12);
                            float   num941    = 4f;                        //speed
                            Vector2 vector104 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2));
                            float   num942    = player.position.X + (float)player.width * 0.5f - vector104.X + (float)Main.rand.Next(-20, 21);
                            float   num943    = player.position.Y + (float)player.height * 0.5f - vector104.Y + (float)Main.rand.Next(-20, 21);
                            float   num944    = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943));
                            num944  = num941 / num944;
                            num942 *= num944;
                            num943 *= num944;
                            //int num946 = 440;
                            vector104.X += num942 * 5f;
                            vector104.Y += num943 * 5f;
                            int num947 = Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, ModContent.ProjectileType <GlitchLaser>(), NPCUtils.ToActualDamage(25, 1.5f), 0f, Main.myPlayer, 0f, 0f);
                            Main.projectile[num947].timeLeft = 300;
                            npc.netUpdate = true;
                        }
                    }
                }
            }
            else
            {
                npc.localAI[0] = 0;
            }
            if ((Main.npc[parent].life <= Main.npc[parent].lifeMax * 0.75f))
            {
                Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 14);
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
                NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <TailProbe>(), npc.whoAmI, 0f, 0f, 0f, 0f, 255);
                Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 0);
                Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 4);
                npc.position.X = npc.position.X + (float)(npc.width / 2);
                npc.position.Y = npc.position.Y + (float)(npc.height / 2);
                npc.width      = 30;
                npc.height     = 30;
                npc.position.X = npc.position.X - (float)(npc.width / 2);
                npc.position.Y = npc.position.Y - (float)(npc.height / 2);
                for (int num621 = 0; num621 < 20; num621++)
                {
                    int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.Electric, 0f, 0f, 100, default, 2f);
 private void Attack()
 {
     if (Main.netMode != NetmodeID.MultiplayerClient)
     {
         var vel = new Vector2(npc.direction * 5, 0);
         Projectile.NewProjectile(npc.Center - vel, vel, ModContent.ProjectileType <PirateLobberBarrel>(), NPCUtils.ToActualDamage(60, 1.3f), 5);
     }
     Main.PlaySound(SoundID.Item, npc.Center, 1);
 }
        private void DaggersP2(Player target)
        {
            int TPTime = 60;

            if (AiTimer <= TPTime)
            {
                npc.TargetClosest(true);
                Vector2 TPPosition = target.Center + (target.velocity.X < 0 ? -1 : 1) * Vector2.UnitX * 550 - Vector2.UnitY * 220;
                TeleportP2(TPPosition, TPTime);
            }
            else
            {
                float timer           = AiTimer - TPTime;       //make timing a bit simpler
                float attacktime      = 140;
                float daggerstarttime = 40;

                if (timer == 1 && !Main.dedServ)
                {
                    Texture2D dagger  = mod.GetTexture("NPCs/Boss/Occultist/Projectiles/OccultistDagger");
                    Texture2D bloom   = mod.GetTexture("Effects/Masks/CircleGradient");
                    float     radius  = 30;
                    float     scale   = 0.5f;
                    float     opacity = 0.8f;
                    for (int i = 0; i < 3; i++)
                    {
                        _rotMan.AddObject(bloom, 0, radius, scale / 3, Color.Pink * opacity * 0.66f, -1, null, 60, 40 * i, MathHelper.Pi);
                        _rotMan.AddObject(dagger, 0, radius, scale, Color.White * opacity, -1, null, 60, 40 * i, MathHelper.Pi);
                    }

                    for (int j = 0; j < 5; j++)
                    {
                        _rotMan.AddObject(bloom, 10, radius * 1.5f, scale / 3, Color.Pink * opacity * 0.66f, -1, null, 60, 24 * j, MathHelper.Pi);
                        _rotMan.AddObject(dagger, 10, radius * 1.5f, scale, Color.White * opacity, -1, null, 60, 24 * j, MathHelper.Pi);
                    }
                }

                if (timer < daggerstarttime)                 //home in on the side of the player that's closer
                {
                    Vector2 DesiredPosition = target.Center + (target.DirectionTo(npc.Center).X < 0 ? -1 : 1) * Vector2.UnitX * 550 - Vector2.UnitY * 220;
                    float   accel           = MathHelper.Clamp(npc.Distance(DesiredPosition) / 400, 0.1f, 0.4f);
                    npc.AccelFlyingMovement(DesiredPosition, accel, 0.15f, 30);
                }
                else                 //move in direction it's facing, with quadratic easing formula to smooth out velocity
                {
                    float progress = Math.Max((timer - daggerstarttime) / (attacktime - daggerstarttime), 0);

                    npc.velocity.Y = (float)Math.Sin(MathHelper.TwoPi * AiTimer / 90);
                    npc.velocity.X = npc.direction * 22f * (progress < 0.5f ? 4 * (float)Math.Pow(progress, 2) : (float)Math.Pow(-2 * progress + 2, 2));
                }

                if (timer % 7 == 0 && Main.netMode != NetmodeID.Server && timer > daggerstarttime)
                {
                    var proj = Projectile.NewProjectileDirect(npc.Center + Main.rand.NextVector2CircularEdge(30, 50), Vector2.Zero,
                                                              ModContent.ProjectileType <OccultistDagger>(), NPCUtils.ToActualDamage(40, 1.5f), 1f, Main.myPlayer,
                                                              Main.rand.NextFloat(-0.12f, 0.12f) + MathHelper.PiOver2);
                    proj.netUpdate = true;
                }

                frame.X = 0;
                UpdateYFrame(7, 0, 2);

                if (timer > attacktime)
                {
                    if (!Main.dedServ)
                    {
                        _rotMan.KillAllObjects();
                    }

                    ResetAttackP2();
                }
            }
        }
        private void SoulsP2(Player target)
        {
            npc.TargetClosest(true);
            int TPTime = 60;

            if (AiTimer <= TPTime)
            {
                npc.TargetClosest(true);
                Vector2 TPPosition = target.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(150, 200);
                TeleportP2(TPPosition, TPTime);
            }
            else
            {
                float timer      = AiTimer - TPTime;            //make timing a bit simpler
                float attacktime = 130;

                frame.X = 1;
                UpdateYFrame(8, 4, 8);

                npc.velocity.Y = (float)Math.Sin(MathHelper.TwoPi * AiTimer / 90);
                npc.velocity.X = MathHelper.Lerp(npc.velocity.X, 0, 0.1f);
                if (timer % 10 == 0)
                {
                    VisualSoul(2.5f);
                }

                if (AiTimer % 20 == 0 && !Main.dedServ)
                {
                    ParticleHandler.SpawnParticle(new PulseCircle(npc.Center, new Color(252, 3, 148, 100) * 0.5f, 120, 12));
                }

                if (timer % 12 == 0 && timer <= 60)
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Vector2 vel = npc.DirectionFrom(target.Center).RotatedByRandom(MathHelper.PiOver2) * 4;
                        Projectile.NewProjectileDirect(npc.Center + vel * Main.rand.NextFloat(10, 20), vel, ModContent.ProjectileType <OccultistSoul>(), NPCUtils.ToActualDamage(30, 1.5f), 1, Main.myPlayer, npc.whoAmI, target.whoAmI).netUpdate = true;
                    }
                }

                if (timer > attacktime)
                {
                    ResetAttackP2();
                }
            }
        }
        public override void AI()
        {
            Player player = Main.player[npc.target];

            npc.TargetClosest(true);
            npc.spriteDirection = npc.direction;

            if (player.dead || !player.active)            //dont attack if no players to attack
            {
                AiState = STATE_IDLE;
                AiTimer = 0;
            }

            switch (AiState)
            {
            case STATE_IDLE:
                frame.X = 0;
                npc.AccelFlyingMovement(player.Center, 0.02f, 0.1f, 0.33f);
                npc.position.Y += 0.66f * (float)Math.Sin(Main.GameUpdateCount / 12f);
                if (AiTimer > IDLETIME)
                {
                    bool teleport = !Collision.CanHit(npc.Center, 0, 0, player.Center, 0, 0) || npc.Distance(player.Center) > TELEPORT_DISTANCE;
                    AiState       = teleport ? STATE_TELEPORT : Main.rand.NextBool() ? STATE_STARGLOOP : STATE_STARBURST;
                    AiTimer       = 0;
                    npc.netUpdate = true;
                }
                break;

            case STATE_TELEPORT:
                frame.X      = 1;
                npc.velocity = Vector2.Zero;

                if (AiTimer == TELEPORT_STARTTIME)
                {
                    Vector2 desiredPos   = player.Center + npc.DirectionTo(player.Center) * (TELEPORT_DISTANCE * 0.75f * Main.rand.NextFloat(0.9f, 1.1f));
                    float   displacement = npc.Distance(desiredPos);
                    if (displacement < TELEPORT_DISTANCE)
                    {
                        desiredPos += npc.DirectionTo(player.Center) * (TELEPORT_DISTANCE - displacement);
                    }

                    npc.Center = desiredPos + new Vector2(0, 30);

                    if (!Main.dedServ)
                    {
                        ParticleHandler.SpawnParticle(new ImpactLine(npc.Center, Vector2.UnitY * 2, Color.White, new Vector2(0.1f, 1f), 10));
                        ParticleHandler.SpawnParticle(new ImpactLine(npc.Center, -Vector2.UnitY * 2, Color.White, new Vector2(0.1f, 1f), 10));
                    }

                    npc.netUpdate = true;
                }

                if (AiTimer >= TELEPORT_ENDTIME + TELEPORT_STARTTIME)
                {
                    if (Vector2.DistanceSquared(npc.Center, player.GetModPlayer <StarjinxPlayer>().StarjinxPosition) > StarjinxMeteorite.EVENT_RADIUS * StarjinxMeteorite.EVENT_RADIUS)
                    {
                        AiState = STATE_TELEPORT_OOB;
                    }
                    else
                    {
                        AiState = Main.rand.NextBool() ? STATE_STARGLOOP : STATE_STARBURST;
                    }
                    AiTimer       = 0;
                    npc.netUpdate = true;
                }
                break;

            case STATE_TELEPORT_OOB:
                frame.X      = 1;
                npc.velocity = Vector2.Zero;

                if (AiTimer == TELEPORT_STARTTIME / 2)
                {
                    Vector2 desiredPos   = player.Center + npc.DirectionTo(player.Center).RotatedByRandom(MathHelper.PiOver4) * (TELEPORT_DISTANCE * 0.75f * Main.rand.NextFloat(0.9f, 1.1f));
                    float   displacement = npc.Distance(desiredPos);
                    if (displacement < TELEPORT_DISTANCE)
                    {
                        desiredPos += npc.DirectionTo(player.Center) * (TELEPORT_DISTANCE - displacement);
                    }

                    npc.Center = desiredPos + new Vector2(0, 30);

                    if (!Main.dedServ)
                    {
                        ParticleHandler.SpawnParticle(new ImpactLine(npc.Center, Vector2.UnitY * 2, Color.White, new Vector2(0.1f, 1f), 10));
                        ParticleHandler.SpawnParticle(new ImpactLine(npc.Center, -Vector2.UnitY * 2, Color.White, new Vector2(0.1f, 1f), 10));
                    }

                    npc.netUpdate = true;
                }

                if (AiTimer >= TELEPORT_ENDTIME + (TELEPORT_STARTTIME / 2))
                {
                    AiState       = Main.rand.NextBool() ? STATE_STARGLOOP : STATE_STARBURST;
                    AiTimer       = 0;
                    npc.netUpdate = true;
                }
                break;

            case STATE_STARBURST:
                frame.X      = 1;
                npc.velocity = Vector2.Zero;

                if (AiTimer == 1)
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ModContent.ProjectileType <WeaverStarChannel>(), NPCUtils.ToActualDamage(80, 1.5f), 1f, Main.myPlayer, npc.whoAmI);
                    }

                    if (!Main.dedServ)
                    {
                        Main.PlaySound(mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/starCast").WithVolume(0.65f).WithPitchVariance(0.3f), npc.Center);
                    }
                }

                if (AiTimer > STARBURST_CHANNELTIME)
                {
                    AiTimer       = -Main.rand.Next(60);
                    AiState       = STATE_IDLE;
                    npc.netUpdate = true;
                }
                break;

            case STATE_STARGLOOP:                     //Attack mostly handled by head projectile, this is just for controlling the body and setting back to another state when done
                frame.X      = 1;
                npc.velocity = Vector2.Zero;

                if (AiTimer > STARGLOOP_TIME)
                {
                    AiTimer       = -Main.rand.Next(60);
                    AiState       = STATE_IDLE;
                    npc.netUpdate = true;
                }
                break;
            }

            void SpawnHead()
            {
                if (Main.netMode == NetmodeID.MultiplayerClient)
                {
                    return;
                }

                var proj = Projectile.NewProjectileDirect(npc.Top - new Vector2(0, 20), Vector2.Zero, ModContent.ProjectileType <StarWeaverHead>(), NPCUtils.ToActualDamage(npc.damage, 1), 1f, Main.myPlayer, npc.whoAmI);

                _headIndex = proj.whoAmI;
                if (Main.netMode != NetmodeID.SinglePlayer)
                {
                    NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, _headIndex);
                }

                npc.netUpdate = true;
            }

            if (_headIndex < 0)
            {
                SpawnHead();
            }
            else if (!Head.active || Head.type != ModContent.ProjectileType <StarWeaverHead>())
            {
                SpawnHead();
            }

            ++AiTimer;
            UpdateYFrame(10, 0, 5);
        }
Exemple #9
0
 void JellyfishRapidFire()
 {
     jellyRapidFire = true;
     attackCounter++;
     if (attackCounter == 1)
     {
         Main.PlaySound(SoundLoader.customSoundType, npc.position, mod.GetSoundSlot(SoundType.Custom, "Sounds/BossSFX/MoonWizard_Laugh2"));
     }
     if (attackCounter % 20 == 0 && attackCounter < 180)
     {
         Vector2 vector2_2  = Vector2.UnitY.RotatedByRandom(1.57079637050629f) * new Vector2(5f, 3f);
         bool    expertMode = Main.expertMode;
         if (Main.netMode != NetmodeID.MultiplayerClient)
         {
             int p = Projectile.NewProjectile(npc.Center.X + Main.rand.Next(-60, 60), npc.Center.Y + Main.rand.Next(-60, 60), vector2_2.X, vector2_2.Y, ModContent.ProjectileType <JellyfishOrbiter>(), NPCUtils.ToActualDamage(40, 1.5f), 0.0f, Main.myPlayer, 0.0f, (float)npc.whoAmI);
             Main.projectile[p].scale = Main.rand.NextFloat(.6f, 1f);
         }
     }
     UpdateFrame(0.15f, 54, 61);
     if (attackCounter > 220)
     {
         jellyRapidFire     = false;
         npc.ai[0]          = 1;
         npc.netUpdate      = true;
         timeBetweenAttacks = 60;
         attackCounter      = 0;
     }
 }
Exemple #10
0
        public override bool PreAI()
        {
            npc.TargetClosest(true);
            Player player = Main.player[npc.target];

            float num5 = npc.position.X + (float)(npc.width / 2) - player.position.X - (float)(player.width / 2);
            float num6 = npc.position.Y + (float)npc.height - 59f - player.position.Y - (float)(player.height / 2);
            float num7 = (float)Math.Atan2((double)num6, (double)num5) + 1.57f;

            if (!(npc.ai[0] >= 100 && npc.ai[0] <= 130))
            {
                if (num7 < 0f)
                {
                    num7 += 6.283f;
                }
                else if ((double)num7 > 6.283)
                {
                    num7 -= 6.283f;
                }
            }
            npc.spriteDirection = npc.direction;
            if (npc.ai[0] == 0)
            {
                npc.ai[1]     = Main.rand.Next(160, 190);
                npc.netUpdate = true;
            }
            npc.ai[0]++;
            if (npc.ai[0] >= npc.ai[1])
            {
                Main.PlaySound(SoundID.Item, npc.Center, 110);
                for (int i = 0; i < 40; i++)
                {
                    int num = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Electric, 0f, -2f, 117, new Color(0, 255, 142), .6f);
                    Main.dust[num].noGravity = true;
                    Dust dust = Main.dust[num];
                    dust.position.X += ((Main.rand.Next(-50, 51) / 20) - 1.5f);
                    dust.position.Y += ((Main.rand.Next(-50, 51) / 20) - 1.5f);
                    if (Main.dust[num].position != npc.Center)
                    {
                        Main.dust[num].velocity = npc.DirectionTo(Main.dust[num].position) * 3f;
                    }
                }
                if (Main.expertMode)
                {
                    npc.Transform(ModContent.NPCType <SuicideLaser>());
                }
                else
                {
                    npc.active = false;
                }
                npc.netUpdate = true;
            }
            else
            {
                npc.velocity.X = 0;
                npc.velocity.Y = 0;
            }
            if (npc.ai[0] <= 75)
            {
                direction9 = player.Center - npc.Center;
                direction9.Normalize();
            }
            if (npc.ai[0] >= 60 && npc.ai[0] <= 110 & npc.ai[0] % 2 == 0)
            {
                {
                    int dust = Dust.NewDust(npc.Center, npc.width, npc.height, DustID.Electric);
                    Main.dust[dust].velocity *= -1f;
                    Main.dust[dust].scale    *= .8f;
                    Main.dust[dust].noGravity = true;
                    Vector2 vector2_1 = new Vector2((float)Main.rand.Next(-80, 81), (float)Main.rand.Next(-80, 81));
                    vector2_1.Normalize();
                    Vector2 vector2_2 = vector2_1 * ((float)Main.rand.Next(50, 100) * 0.04f);
                    Main.dust[dust].velocity = vector2_2;
                    vector2_2.Normalize();
                    Vector2 vector2_3 = vector2_2 * 34f;
                    Main.dust[dust].position = npc.Center - vector2_3;
                }
            }
            if (npc.alpha != 255)
            {
                if (Main.rand.NextFloat() < 0.5f)
                {
                    Vector2 position = new Vector2(npc.Center.X - 10, npc.Center.Y);
                    Dust.NewDustPerfect(position, 226, new Vector2(0f, -6.421053f).RotatedBy(npc.rotation), 0, new Color(255, 0, 0), 0.6578947f);
                }
                if (Main.rand.NextFloat() < 0.5f)
                {
                    Vector2 position = new Vector2(npc.Center.X + 10, npc.Center.Y);
                    Dust.NewDustPerfect(position, 226, new Vector2(0f, -6.421053f).RotatedBy(npc.rotation), 0, new Color(255, 0, 0), 0.6578947f);
                }

                if (npc.ai[0] == 110)                 //change to frame related later
                {
                    Main.PlaySound(SoundID.NPCHit, (int)npc.position.X, (int)npc.position.Y, 53);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)direction9.X * 40, (float)direction9.Y * 40, ModContent.ProjectileType <StarLaser>(), NPCUtils.ToActualDamage(55, 1.5f), 1, Main.myPlayer);
                }
                if (npc.ai[0] < 110 && npc.ai[0] > 75 && npc.ai[0] % 3 == 0)
                {
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)direction9.X * 30, (float)direction9.Y * 30, ModContent.ProjectileType <StarLaserTrace>(), NPCUtils.ToActualDamage(27, 1.5f), 1, Main.myPlayer);
                }
                npc.rotation = direction9.ToRotation() - 1.57f;
            }
            return(false);
        }
Exemple #11
0
        public override bool PreAI()
        {
            npc.TargetClosest(true);
            if (lifeSpan <= 0)
            {
                npc.life   = 0;
                npc.active = false;
            }
            Player player = Main.player[npc.target];

            if (lifeSpan % 250 == 0)
            {
                distAbove = 375;
                if (Main.rand.Next(2) == 0)
                {
                    npc.position.X = player.Center.X - Main.rand.Next(300, 500);
                    npc.position.Y = player.Center.Y - distAbove;
                    npc.velocity.X = 3f;
                }
                else
                {
                    npc.position.X = player.Center.X + Main.rand.Next(300, 500);
                    npc.position.Y = player.Center.Y - distAbove;
                    npc.velocity.X = -3f;
                }
                npc.rotation  = 0f;
                npc.netUpdate = true;
            }
            npc.velocity.Y = 0;
            if (lifeSpan % fireRate == 0)
            {
                Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 91);
                for (int i = 0; i < 16; i++)
                {
                    int dust = Dust.NewDust(npc.Center, npc.width, npc.height, DustID.GoldCoin);

                    Main.dust[dust].velocity *= -1f;
                    Main.dust[dust].noGravity = true;
                    //        Main.dust[dust].scale *= 2f;
                    Vector2 vector2_1 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
                    vector2_1.Normalize();
                    Vector2 vector2_2 = vector2_1 * ((float)Main.rand.Next(50, 100) * 0.04f);
                    Main.dust[dust].velocity = vector2_2;
                    vector2_2.Normalize();
                    Vector2 vector2_3 = vector2_2 * 34f;
                    Main.dust[dust].position = (npc.Center) - vector2_3;
                }
                Projectile.NewProjectile(npc.Center, new Vector2(0, 10), ModContent.ProjectileType <GlitchLaser>(), NPCUtils.ToActualDamage(55, 1.5f), 1, Main.myPlayer, 0, 0);
            }
            lifeSpan--;
            return(false);
        }
Exemple #12
0
        public override bool PreAI()
        {
            var exposedBodies = Main.npc.Where(x => x.active && (x.type == ModContent.NPCType <SteamRaiderBody>() || x.type == ModContent.NPCType <SteamRaiderBody2>()) && x.localAI[0] > 0).Count();

            if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                if (exposedBodies < 7 && Main.rand.NextBool(50) || (++npc.localAI[1] % 60 == 0 && Main.rand.NextBool(50)))
                {
                    if (!Exposed)
                    {
                        npc.localAI[0] = 1;
                        npc.netUpdate  = true;
                    }
                }
                if (exposedBodies > 10 || (npc.localAI[1] % 60 == 0 && Main.rand.NextBool(50)))
                {
                    if (Exposed)
                    {
                        npc.localAI[0] = 0;
                        npc.netUpdate  = true;
                    }
                }
                if (npc.localAI[2] >= 601)
                {
                    npc.localAI[2] = 0f;
                }
            }
            if (Exposed)
            {
                npc.defense        = 8;
                npc.dontTakeDamage = false;
            }
            else
            {
                npc.defense        = 9999;
                npc.dontTakeDamage = true;
            }
            Player player = Main.player[npc.target];

            Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0f, 0.075f, 0.25f);
            if (Head.ai[2] == 1)
            {
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    if (--npc.ai[3] == 0)
                    {
                        Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 9);
                        npc.TargetClosest(true);
                        npc.netUpdate = true;
                        if (Main.rand.NextBool(2))
                        {
                            float   num941    = 1f;                        //speed
                            Vector2 vector104 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2));
                            float   num942    = player.position.X + (float)player.width * 0.5f - vector104.X + (float)Main.rand.Next(-20, 21);
                            float   num943    = player.position.Y + (float)player.height * 0.5f - vector104.Y + (float)Main.rand.Next(-20, 21);
                            float   num944    = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943));
                            num944  = num941 / num944;
                            num942 *= num944;
                            num943 *= num944;
                            num942 += (float)Main.rand.Next(-10, 11) * 0.0125f;
                            num943 += (float)Main.rand.Next(-10, 11) * 0.0125f;
                            int num946 = ModContent.ProjectileType <Starshock>();
                            vector104.X += num942 * 4f;
                            vector104.Y += num943 * 2.5f;
                            int num947 = Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, num946, NPCUtils.ToActualDamage(30, 1.25f), 0f, Main.myPlayer, 0f, 0f);
                            Main.projectile[num947].timeLeft = 350;
                        }
                    }
                }
            }
            else
            {
                npc.ai[3] = Main.rand.Next(175, 190);
            }

            if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].life <= Main.npc[(int)npc.ai[1]].lifeMax * .2f)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
            }
            if (Main.npc[(int)npc.ai[1]].alpha < 128)
            {
                if (npc.alpha != 0)
                {
                    for (int num934 = 0; num934 < 2; num934++)
                    {
                        int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 226, 0f, 0f, 100, default, 2f);
Exemple #13
0
        public override bool PreAI()
        {
            timer++;
            Lighting.AddLight(new Vector2(npc.Center.X, npc.Center.Y), 0.075f * 2, 0.231f * 2, 0.255f * 2);
            npc.spriteDirection = -npc.direction;
            Player   target    = Main.player[npc.target];
            MyPlayer modPlayer = target.GetSpiritPlayer();

            npc.spriteDirection = npc.direction;
            float num1      = 5f;
            float moveSpeed = 0.05f;

            npc.TargetClosest(true);
            Vector2 vector2_1 = Main.player[npc.target].Center - npc.Center + new Vector2(0, -100f);
            float   num2      = vector2_1.Length();
            Vector2 desiredVelocity;

            if ((double)num2 < 20.0)
            {
                desiredVelocity = npc.velocity;
            }
            else if ((double)num2 < 40.0)
            {
                vector2_1.Normalize();
                desiredVelocity = vector2_1 * (num1 * 0.025f);
            }
            else if ((double)num2 < 80.0)
            {
                vector2_1.Normalize();
                desiredVelocity = vector2_1 * (num1 * 0.075f);
            }
            else
            {
                vector2_1.Normalize();
                desiredVelocity = vector2_1 * num1;
            }
            npc.SimpleFlyMovement(desiredVelocity, moveSpeed);
            npc.rotation = npc.velocity.X * 0.1f;
            if (npc.ai[0] == 0f)
            {
                for (int i = 0; i < 5; i++)
                {
                    Vector2 vector2_2  = Vector2.UnitY.RotatedByRandom(3.14159237050629f) * new Vector2(Main.rand.Next(3, 8), Main.rand.Next(3, 8));
                    bool    expertMode = Main.expertMode;
                    int     p          = Projectile.NewProjectile(npc.Center.X + Main.rand.Next(-20, 20), npc.Center.Y + Main.rand.Next(-20, 20), vector2_2.X, vector2_2.Y, ModContent.ProjectileType <ElectricJellyfishOrbiter>(), NPCUtils.ToActualDamage(10, 1.5f), 0.0f, Main.myPlayer, 0.0f, (float)npc.whoAmI);
                    Main.projectile[p].scale = Main.rand.NextFloat(.6f, .95f);
                    Main.projectile[p].ai[0] = npc.whoAmI;

                    npc.ai[0]     = 1f;
                    npc.netUpdate = true;
                }
            }
            return(false);
        }
Exemple #14
0
        public override void AI()
        {
            if (!NPC.AnyNPCs(ModContent.NPCType <SteamRaiderHead>()))
            {
                npc.active     = false;
                npc.position.X = npc.position.X + (npc.width / 2.0f);
                npc.position.Y = npc.position.Y + (npc.height / 2.0f);
                npc.width      = 30;
                npc.height     = 30;
                npc.position.X = npc.position.X - (npc.width / 2.0f);
                npc.position.Y = npc.position.Y - (npc.height / 2.0f);
                for (int num621 = 0; num621 < 10; num621++)
                {
                    int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 226, 0f, 0f, 100, default(Color), .8f);
                    Main.dust[num622].velocity *= 1f;
                    if (Main.rand.Next(2) == 0)
                    {
                        Main.dust[num622].scale = 0.5f;
                    }
                }
                return;
            }
            Player player = Main.player[npc.target];

            /*for (int i = 0; i < 255; ++i)
             *              {
             *                      if (Main.player[i].active && !Main.player[i].dead)
             *                      {
             *                              if ((Main.player[i].Center - npc.Center).Length() <= 120)
             *                              {
             *                                      //Main.player[i].Hurt(1, 0, false, false, " was evaporated...", false, 1); commed out because this needs work
             *                                      Main.player[i].AddBuff(BuffID.Slow, 90);
             *                              }
             *                      }
             *              }*/
            int parent = NPC.FindFirstNPC(ModContent.NPCType <SteamRaiderHead>());
            {
                if (Main.npc[parent].life <= Main.npc[parent].lifeMax * .2f)
                {
                    npc.life = 0;
                    npc.HitEffect(0, 10.0);
                    npc.active = false;
                }
            }
            float num5 = base.npc.position.X + (float)(base.npc.width / 2) - player.position.X - (float)(player.width / 2);
            float num6 = base.npc.position.Y + (float)base.npc.height - 59f - player.position.Y - (float)(player.height / 2);
            float num7 = (float)Math.Atan2((double)num6, (double)num5) + 1.57f;

            if (num7 < 0f)
            {
                num7 += 6.283f;
            }
            else if ((double)num7 > 6.283)
            {
                num7 -= 6.283f;
            }
            float num8 = 0.1f;

            if (base.npc.rotation < num7)
            {
                if ((double)(num7 - base.npc.rotation) > 3.1415)
                {
                    base.npc.rotation -= num8;
                }
                else
                {
                    base.npc.rotation += num8;
                }
            }
            else if (base.npc.rotation > num7)
            {
                if ((double)(base.npc.rotation - num7) > 3.1415)
                {
                    base.npc.rotation += num8;
                }
                else
                {
                    base.npc.rotation -= num8;
                }
            }
            if (base.npc.rotation > num7 - num8 && base.npc.rotation < num7 + num8)
            {
                base.npc.rotation = num7;
            }
            if (base.npc.rotation < 0f)
            {
                base.npc.rotation += 6.283f;
            }
            else if ((double)base.npc.rotation > 6.283)
            {
                base.npc.rotation -= 6.283f;
            }
            if (base.npc.rotation > num7 - num8 && base.npc.rotation < num7 + num8)
            {
                base.npc.rotation = num7;
            }
            base.npc.spriteDirection = base.npc.direction;
            if (Main.npc[parent].ai[2] == 0)
            {
                shoottimer++;
                if (shoottimer >= 120 && shoottimer <= 180)
                {
                    {
                        int dust = Dust.NewDust(npc.Center, npc.width, npc.height, DustID.GoldCoin);
                        Main.dust[dust].velocity *= -1f;
                        Main.dust[dust].scale    *= .8f;
                        Main.dust[dust].noGravity = true;
                        Vector2 vector2_1 = new Vector2((float)Main.rand.Next(-80, 81), (float)Main.rand.Next(-80, 81));
                        vector2_1.Normalize();
                        Vector2 vector2_2 = vector2_1 * ((float)Main.rand.Next(50, 100) * 0.04f);
                        Main.dust[dust].velocity = vector2_2;
                        vector2_2.Normalize();
                        Vector2 vector2_3 = vector2_2 * 34f;
                        Main.dust[dust].position = npc.Center - vector2_3;
                    }
                }
                {
                    if (shoottimer >= 180 && shoottimer % 10 == 0)
                    {
                        Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 12);
                        Vector2 direction = Main.player[npc.target].Center - npc.Center;
                        direction.Normalize();
                        direction.X *= 6f;
                        direction.Y *= 6f;

                        if (Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            Projectile.NewProjectile(npc.Center.X, npc.Center.Y, direction.X, direction.Y, ModContent.ProjectileType <GlitchLaser>(), NPCUtils.ToActualDamage(32, 1.5f), 1, Main.myPlayer, 0, 0);
                        }

                        if (!Main.expertMode || shoottimer >= 200)
                        {
                            shoottimer = 0;
                        }
                    }
                }
            }
            else
            {
                shoottimer = 0;
            }

            npc.TargetClosest(true);
            if (npc.direction == -1)
            {
                Vector2 direction = Main.player[npc.target].Center - npc.Center;
                direction.Normalize();
                direction *= 12f;
            }
            if (npc.direction == 1)
            {
                Vector2 direction = Main.player[npc.target].Center - npc.Center;
                direction.Normalize();
                direction *= -12f;
            }
            if (npc.Center.X >= player.Center.X && moveSpeed >= -80)             // flies to players x position
            {
                moveSpeed--;
            }

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

            npc.velocity.X = moveSpeed * 0.12f;

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

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

            npc.velocity.Y = moveSpeedY * 0.14f;
            if (Main.rand.Next(220) == 33)
            {
                HomeY = -35f;
            }
            Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), .25f, .57f, .85f);
            npc.spriteDirection = npc.direction;
        }
        private void BruteP1(Player Target)
        {
            int   chargeTime    = 40;
            float circleOpacity = 0.66f;
            int   bruteSlamTime = BruteSlam.TOTALTIME;
            int   restTime      = 60;

            if (AiTimer < chargeTime)
            {
                npc.TargetClosest(true);
            }

            if (AiTimer <= chargeTime + bruteSlamTime)
            {
                UpdateYFrame(8, 0, 8, null, 4);
                _ritualCircle = Math.Min(_ritualCircle + circleOpacity / chargeTime, circleOpacity);

                if (AiTimer == chargeTime)
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        var proj = Projectile.NewProjectileDirect(npc.Bottom, Vector2.Zero, ModContent.ProjectileType <BruteSlam>(), NPCUtils.ToActualDamage(60, 1.5f), 1, Main.myPlayer, npc.whoAmI);
                        proj.position.Y -= proj.height * 0.66f;
                        if (Main.netMode != NetmodeID.SinglePlayer)
                        {
                            NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj.whoAmI);
                        }
                    }
                }
            }
            else
            {
                _ritualCircle = Math.Max(_ritualCircle - circleOpacity / restTime, 0f);
                UpdateYFrame(8, 8, 0, null, 0);
            }

            ResetAttackP1(chargeTime + bruteSlamTime + restTime);
        }
Exemple #16
0
        void SmashAttack()
        {
            Player player = Main.player[npc.target];

            npc.rotation = 3.14f;
            if (attackCounter < 30 && attackCounter > 10)
            {
                npc.position.X = player.position.X;
                npc.position.Y = player.position.Y - 300;
            }
            attackCounter++;
            if (attackCounter < 30)
            {
                UpdateFrame(0.2f, 4, 9);
            }
            else
            {
                UpdateFrame(0.4f, 4, 9);
                if (attackCounter == 55)
                {
                    Main.PlaySound(SoundLoader.customSoundType, npc.position, mod.GetSoundSlot(SoundType.Custom, "Sounds/BossSFX/MoonWizard_Attack"));
                    npc.velocity.Y  = 13;
                    npc.velocity.Y += 1.6f;
                    if (phaseTwo)
                    {
                        npc.velocity.Y = 20;
                        attackCounter++;
                    }
                    npc.netUpdate = true;
                    Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 81);
                }
            }
            if (Main.netMode != NetmodeID.MultiplayerClient && (Main.tile[(int)(npc.Center.X / 16), (int)(npc.Center.Y / 16)].collisionType == 1 || attackCounter > 75))
            {
                for (int i = 0; i < Main.rand.Next(9, 15); i++)
                {
                    Projectile.NewProjectile(npc.Center, new Vector2(Main.rand.NextFloat(-10, 10), Main.rand.NextFloat(3.2f)), mod.ProjectileType("MoonBubble"), NPCUtils.ToActualDamage(40, 1.5f), 3);
                }
                Teleport();
                npc.ai[0]          = 0;
                npc.netUpdate      = true;
                timeBetweenAttacks = 20;
                attackCounter      = 0;
            }
        }
        private void WaveHandsP2(Player target)
        {
            npc.TargetClosest(true);
            int TPTime = 60;

            if (AiTimer <= TPTime)
            {
                Vector2 TPPosition = target.Center + (target.velocity.X < 0 ? -1 : 1) * Vector2.UnitX * 300;
                TeleportP2(TPPosition, TPTime);
            }
            else
            {
                float timer = AiTimer - TPTime;                 //make timing a bit simpler
                if (timer % 6 == 0)
                {
                    AddRune();
                }

                if (timer < 80)                 //home in on the side of the player that's closer
                {
                    Vector2 DesiredPosition = target.Center + (target.DirectionTo(npc.Center).X < 0 ? -1 : 1) * Vector2.UnitX * 300;
                    DesiredPosition.Y += (float)Math.Sin(Main.GameUpdateCount / 10f) * 20;
                    float accel = MathHelper.Clamp(npc.Distance(DesiredPosition) / 400, 0.1f, 0.4f);
                    npc.AccelFlyingMovement(DesiredPosition, accel, 0.1f, 30);
                }
                else
                {
                    npc.velocity = Vector2.Lerp(npc.velocity, Vector2.Zero, 0.085f);
                }

                if (timer > 80)
                {
                    frame.X = 1;
                    UpdateYFrame(8, 0, 8, delegate(int frameY)
                    {
                        if (frameY == 4 && Main.netMode != NetmodeID.MultiplayerClient && timer < 150)
                        {
                            Vector2 spawnPos = npc.Center + (Vector2.UnitX * npc.direction).RotatedByRandom(MathHelper.Pi / 4) * Main.rand.NextFloat(20, 40);
                            float amplitude  = 70;
                            for (int i = -1; i <= 1; i++)
                            {
                                if (i == 0)
                                {
                                    continue;
                                }

                                Projectile.NewProjectileDirect(spawnPos, npc.direction * Vector2.UnitX * 2.25f, ModContent.ProjectileType <OccultistHandFiery>(), NPCUtils.ToActualDamage(40, 1.5f), 1f, Main.myPlayer, amplitude * i, 60).netUpdate = true;
                            }
                            npc.velocity.X -= npc.direction * 5;
                            npc.netUpdate   = true;
                        }
                    }, 4);
                }
                else
                {
                    frame.X = 0;
                    UpdateYFrame(4, 0, 2);
                    if (timer == 80)
                    {
                        frame.Y = 0;
                    }
                }

                if (timer > 180)
                {
                    ResetAttackP2();
                }
            }
        }
        public override bool PreAI()
        {
            npc.TargetClosest(true);
            Lighting.AddLight(new Vector2(npc.Center.X, npc.Center.Y), 0.075f * 2, 0.231f * 2, 0.255f * 2);

            Player target = Main.player[npc.target];

            npc.spriteDirection = npc.direction;

            Vector2 vector2_1 = target.Center - npc.Center + new Vector2(0, -100f);
            float   distance  = vector2_1.Length();

            Vector2 desiredVelocity = npc.velocity;

            if (distance < 20)
            {
                desiredVelocity.Normalize();
            }

            if (distance < 40.0)
            {
                desiredVelocity = vector2_1 * (5f * 0.025f);
            }
            else if (distance < 80.0)
            {
                desiredVelocity = vector2_1 * (5f * 0.075f);
            }
            else
            {
                desiredVelocity = vector2_1 * 5f;
            }

            npc.SimpleFlyMovement(desiredVelocity, 0.05f);
            npc.rotation = npc.velocity.X * 0.1f;

            if (npc.ai[0] == 0f)
            {
                for (int i = 0; i < 5; i++)
                {
                    Vector2 vel = Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * new Vector2(Main.rand.Next(3, 8), Main.rand.Next(3, 8));
                    int     p   = Projectile.NewProjectile(npc.Center.X + Main.rand.Next(-20, 20), npc.Center.Y + Main.rand.Next(-20, 20), vel.X, vel.Y, ModContent.ProjectileType <ElectricJellyfishOrbiter>(), NPCUtils.ToActualDamage(10, 1.5f), 0.0f, Main.myPlayer, 0.0f, npc.whoAmI);
                    Main.projectile[p].scale = Main.rand.NextFloat(.6f, .95f);
                    Main.projectile[p].ai[0] = npc.whoAmI;

                    npc.ai[0]     = 1f;
                    npc.netUpdate = true;
                }
            }
            return(false);
        }
        private void WaveHandsP1(Player target)
        {
            int chargetime          = 40;
            int attacktelegraphtime = 30;
            int attacktime          = 30;

            if (AiTimer < chargetime)
            {
                npc.TargetClosest(true);
                if (AiTimer % 6 == 0)
                {
                    AddRune();
                }
            }

            if (AiTimer == chargetime && !Main.dedServ)
            {
                ParticleHandler.SpawnParticle(new OccultistTelegraphBeam(npc, (Vector2.UnitX * npc.direction).ToRotation(), 400, attacktelegraphtime));
            }

            if (AiTimer > attacktelegraphtime + chargetime)
            {
                UpdateYFrame(11, 4, 8);
                if (AiTimer % 6 == 0)
                {
                    Vector2 spawnPos = npc.Center + (Vector2.UnitX * npc.direction).RotatedByRandom(MathHelper.Pi / 4) * Main.rand.NextFloat(20, 40);
                    Vector2 velocity = npc.direction * Vector2.UnitX * Main.rand.NextFloat(3, 4);
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        float amplitude    = Main.rand.NextFloat(5, 8);
                        float periodOffset = Main.rand.Next(160);
                        var   proj         = Projectile.NewProjectileDirect(spawnPos, velocity, ModContent.ProjectileType <OccultistHand>(), NPCUtils.ToActualDamage(40, 1.5f), 1f, Main.myPlayer, amplitude, periodOffset);
                        proj.netUpdate = true;
                    }
                }
            }
            else
            {
                UpdateYFrame(8, 0, 8, null, 4);
            }

            ResetAttackP1(attacktelegraphtime + chargetime + attacktime);
        }
        public override void AI()
        {
            Player player     = Main.player[npc.target];
            bool   expertMode = Main.expertMode;

            Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0f, 0.075f, 0.25f);
            int parent = NPC.FindFirstNPC(ModContent.NPCType <SteamRaiderHead>());

            if (parent < 0 || parent >= Main.npc.Length)
            {
                npc.active = false;
                return;
            }
            if (!Main.npc[(int)npc.ai[1]].active)
            {
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
            }
            if (Main.npc[parent].ai[2] != 1)
            {
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    npc.localAI[0] += expertMode ? 2f : 1f;
                    if (npc.localAI[0] >= 200f)
                    {
                        npc.localAI[0] = 0f;
                        npc.TargetClosest(true);
                        if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height))
                        {
                            Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 12);
                            float   num941    = 4f;                        //speed
                            Vector2 vector104 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2));
                            float   num942    = player.position.X + (float)player.width * 0.5f - vector104.X + (float)Main.rand.Next(-20, 21);
                            float   num943    = player.position.Y + (float)player.height * 0.5f - vector104.Y + (float)Main.rand.Next(-20, 21);
                            float   num944    = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943));
                            num944  = num941 / num944;
                            num942 *= num944;
                            num943 *= num944;
                            //int num946 = 440;
                            vector104.X += num942 * 5f;
                            vector104.Y += num943 * 5f;
                            int num947 = Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, ModContent.ProjectileType <GlitchLaser>(), NPCUtils.ToActualDamage(25, 1.5f), 0f, Main.myPlayer, 0f, 0f);
                            Main.projectile[num947].timeLeft = 300;
                            npc.netUpdate = true;
                        }
                    }
                }
            }
            else
            {
                npc.localAI[0] = 0;
            }
            if ((Main.npc[parent].life <= Main.npc[parent].lifeMax * 0.75f))
            {
                Main.PlaySound(SoundID.Item, (int)npc.Center.X, (int)npc.Center.Y, 14);
                npc.life = 0;
                npc.HitEffect(0, 10.0);
                npc.active = false;
                NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <TailProbe>(), npc.whoAmI, 0f, 0f, 0f, 0f, 255);
                Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 0);
                Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 4);
                npc.position.X = npc.position.X + (float)(npc.width / 2);
                npc.position.Y = npc.position.Y + (float)(npc.height / 2);
                npc.width      = 30;
                npc.height     = 30;
                npc.position.X = npc.position.X - (float)(npc.width / 2);
                npc.position.Y = npc.position.Y - (float)(npc.height / 2);
                for (int num621 = 0; num621 < 20; num621++)
                {
                    int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 226, 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num622].velocity *= 3f;
                    if (Main.rand.Next(2) == 0)
                    {
                        Main.dust[num622].scale  = 0.5f;
                        Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
                    }
                }
                for (int num623 = 0; num623 < 40; num623++)
                {
                    int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 226, 0f, 0f, 100, default(Color), 3f);
                    Main.dust[num624].noGravity = true;
                    Main.dust[num624].velocity *= 5f;
                    num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default(Color), 2f);
                    Main.dust[num624].velocity *= 2f;
                }
            }
            if (Main.npc[(int)npc.ai[1]].alpha < 128)
            {
                if (npc.alpha != 0)
                {
                    for (int num934 = 0; num934 < 2; num934++)
                    {
                        int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 226, 0f, 0f, 100, default(Color), 2f);
                        Main.dust[num935].noGravity = true;
                        Main.dust[num935].noLight   = true;
                    }
                }
                npc.alpha -= 42;
                if (npc.alpha < 0)
                {
                    npc.alpha = 0;
                }
            }
            if (npc.ai[2] > 0)
            {
                npc.realLife = (int)npc.ai[2];
            }

            if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
            {
                npc.TargetClosest(true);
            }

            if (npc.ai[1] < (double)Main.npc.Length)
            {
                // We're getting the center of this NPC.
                Vector2 npcCenter = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
                // Then using that center, we calculate the direction towards the 'parent NPC' of this NPC.
                float dirX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - npcCenter.X;
                float dirY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - npcCenter.Y;
                // We then use Atan2 to get a correct rotation towards that parent NPC.
                npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
                // We also get the length of the direction vector.
                float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
                // We calculate a new, correct distance.
                float dist = (length - (float)npc.width) / length;
                float posX = dirX * dist;
                float posY = dirY * dist;

                // Reset the velocity of this NPC, because we don't want it to move on its own
                npc.velocity = Vector2.Zero;
                // And set this NPCs position accordingly to that of this NPCs parent NPC.
                npc.position.X = npc.position.X + posX;
                npc.position.Y = npc.position.Y + posY;
            }
        }
        private void DaggersP1(Player target)
        {
            int daggerspintime = 40;

            if (AiTimer < daggerspintime)
            {
                npc.TargetClosest(true);
            }
            else
            {
                UpdateYFrame(8, 0, 8, null, 4);
            }

            if ((AiTimer == 1 || AiTimer == 20) && !Main.dedServ)
            {
                Texture2D dagger  = mod.GetTexture("NPCs/Boss/Occultist/Projectiles/OccultistDagger");
                Texture2D bloom   = mod.GetTexture("Effects/Masks/CircleGradient");
                float     height  = AiTimer == 1 ? 0 : -10;
                float     radius  = AiTimer == 1 ? 30 : 40;
                float     scale   = AiTimer == 1 ? 0.25f : 0.5f;
                float     opacity = AiTimer == 1 ? 0.66f : 0.8f;
                float     offset  = AiTimer == 1 ? 0 : 10;
                for (int i = 0; i < 3; i++)
                {
                    _rotMan.AddObject(bloom, height, radius, scale / 3, Color.Pink * opacity * 0.66f, -1, null, 60, 40 * i + offset);
                    _rotMan.AddObject(dagger, height, radius, scale, Color.White * opacity, -1, null, 60, 40 * i + offset);
                }
            }

            if (AiTimer == daggerspintime && !Main.dedServ)
            {
                _rotMan.KillAllObjects();
            }

            if (AiTimer > daggerspintime && AiTimer % 5 == 0 && AiTimer <= daggerspintime + 30)
            {
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    float timer = AiTimer - daggerspintime + 10;
                    if (npc.direction > 0)
                    {
                        timer = 40 - timer;
                    }

                    float   angle    = timer / 40 * MathHelper.Pi;
                    Vector2 spawnPos = npc.Center - new Vector2(0, 500) + new Vector2(0, 300).RotatedBy((angle - MathHelper.PiOver2) / 2.5f);
                    var     proj     = Projectile.NewProjectileDirect(spawnPos, Vector2.Zero, ModContent.ProjectileType <OccultistDagger>(), NPCUtils.ToActualDamage(40, 1.5f), 1f, Main.myPlayer, angle);
                    proj.netUpdate = true;
                }
            }

            ResetAttackP1(daggerspintime + 60);
        }
 public override void AI()
 {
     Lighting.AddLight(npc.Center, Color.Blue.ToVector3() * 0.3f);
     if (!initialized)
     {
         proj        = Projectile.NewProjectileDirect(npc.Center, Vector2.Zero, ModContent.ProjectileType <NemesisBoonSword>(), NPCUtils.ToActualDamage(npc.damage), 5, 255);
         proj.ai[0]  = npc.whoAmI;
         initialized = true;
     }
 }