コード例 #1
0
        public override void AI()
        {
            if (!Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height))
            {
                //dust!
                int dustId = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 60, Projectile.velocity.X * 0.2f,
                                          Projectile.velocity.Y * 0.2f, 100, default(Color), 2f);
                Main.dust[dustId].noGravity = true;
            }

            const int   aislotHomingCooldown            = 0;
            const int   homingDelay                     = 10;
            const float desiredFlySpeedInPixelsPerFrame = 10;
            const float amountOfFramesToLerpBy          = 10; // minimum of 1, please keep in full numbers even though it's a float!

            Projectile.ai[aislotHomingCooldown]++;
            if (Projectile.ai[aislotHomingCooldown] > homingDelay)
            {
                Projectile.ai[aislotHomingCooldown] = homingDelay; //cap this value

                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1000));
                if (n != null)
                {
                    Vector2 desiredVelocity = Projectile.DirectionTo(n.Center) * desiredFlySpeedInPixelsPerFrame;
                    Projectile.velocity = Vector2.Lerp(Projectile.velocity, desiredVelocity, 1f / amountOfFramesToLerpBy);
                }
            }
        }
コード例 #2
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            projectile.timeLeft = 2;

            if (player.whoAmI == Main.myPlayer && (!player.active || player.dead || !player.GetModPlayer <FargoPlayer>().RainbowSlime))
            {
                projectile.Kill();
                return;
            }

            if (projectile.damage == 0)
            {
                projectile.damage = (int)(35 * player.minionDamage);
                if (player.GetModPlayer <FargoPlayer>().MasochistSoul)
                {
                    projectile.damage *= 2;
                }
            }

            if (++counter > 150) //periodically do bonus attack
            {
                counter = 0;
                if (projectile.owner == Main.myPlayer && FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 600, true) != -1)
                {
                    for (int j = 0; j < 15; j++) //spray spikes
                    {
                        Projectile.NewProjectile(projectile.Center, new Vector2(Main.rand.NextFloat(-6, 6), Main.rand.NextFloat(-8, -5)), mod.ProjectileType("RainbowSlimeSpikeFriendly"), projectile.damage / 10, projectile.knockBack, Main.myPlayer);
                    }
                }
            }

            //Main.NewText(projectile.ai[0].ToString() + " " + projectile.ai[1].ToString() + " " + projectile.localAI[0].ToString() + " " + projectile.localAI[1].ToString());
        }
コード例 #3
0
        public override void AI()
        {
            Player player = Main.player[Projectile.owner];

            Projectile.timeLeft = 2;

            if (player.whoAmI == Main.myPlayer && (!player.active || player.dead || player.ghost || !player.GetModPlayer <FargoSoulsPlayer>().RainbowSlime))
            {
                Projectile.Kill();
                return;
            }

            /*if (Projectile.damage == 0)
             * {
             *  Projectile.damage = (int)(35 * player.GetDamage(DamageClass.Summon));
             *  if (player.GetModPlayer<FargoSoulsPlayer>().MasochistSoul)
             *      Projectile.damage *= 2;
             * }*/

            if (++counter > 150) //periodically do bonus attack
            {
                counter = 0;
                if (Projectile.owner == Main.myPlayer && FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 600, true) != -1)
                {
                    for (int j = 0; j < 15; j++) //spray spikes
                    {
                        FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(Main.rand.NextFloat(-6, 6), Main.rand.NextFloat(-8, -5)), ModContent.ProjectileType <RainbowSlimeSpikeFriendly>(), Projectile.originalDamage / 10, Projectile.knockBack, Main.myPlayer);
                    }
                }
            }

            //Main.NewText(Projectile.ai[0].ToString() + " " + Projectile.ai[1].ToString() + " " + Projectile.localAI[0].ToString() + " " + Projectile.localAI[1].ToString());
        }
コード例 #4
0
        public override void AI()
        {
            base.AI();

            projectile.ai[1]++;

            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[0]);

            if (npc != null)
            {
                if (projectile.ai[1] < 60)
                {
                    float   rotation    = projectile.velocity.ToRotation();
                    Vector2 vel         = npc.Center - projectile.Center;
                    float   targetAngle = vel.ToRotation();
                    projectile.velocity = new Vector2(projectile.velocity.Length(), 0f).RotatedBy(rotation.AngleLerp(targetAngle, 0.05f));
                }
            }
            else
            {
                projectile.ai[0] = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 750);
            }

            if (projectile.ai[1] < 60)
            {
                projectile.velocity *= 1.065f;
            }
        }
コード例 #5
0
        public override void AI()
        {
            //dust!
            int dustId = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width, projectile.height + 5, DustID.Shadowflame, projectile.velocity.X * 0.2f,
                                      projectile.velocity.Y * 0.2f, 100, default(Color), 1f);

            Main.dust[dustId].noGravity = true;
            int dustId3 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width, projectile.height + 5, DustID.Shadowflame, projectile.velocity.X * 0.2f,
                                       projectile.velocity.Y * 0.2f, 100, default(Color), 1f);

            Main.dust[dustId3].noGravity = true;

            const int   aislotHomingCooldown            = 0;
            const int   homingDelay                     = 15;
            const float desiredFlySpeedInPixelsPerFrame = 15;
            const float amountOfFramesToLerpBy          = 20; // minimum of 1, please keep in full numbers even though it's a float!

            projectile.ai[aislotHomingCooldown]++;
            if (projectile.ai[aislotHomingCooldown] > homingDelay)
            {
                projectile.ai[aislotHomingCooldown] = homingDelay; //cap this value

                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 1000));
                if (n != null)
                {
                    Vector2 desiredVelocity = projectile.DirectionTo(n.Center) * desiredFlySpeedInPixelsPerFrame;
                    projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / amountOfFramesToLerpBy);
                }
            }
        }
コード例 #6
0
        public override void AI()
        {
            if (speed == 0) //store homing speed
            {
                speed = Projectile.velocity.Length() * 2f;
            }

            const int   aislotHomingCooldown            = 0;
            const int   homingDelay                     = 15;
            float       desiredFlySpeedInPixelsPerFrame = speed;
            const float amountOfFramesToLerpBy          = 10; // minimum of 1, please keep in full numbers even though it's a float!

            Projectile.ai[aislotHomingCooldown]++;
            if (Projectile.ai[aislotHomingCooldown] > homingDelay)
            {
                Projectile.ai[aislotHomingCooldown] = homingDelay; //cap this value

                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 600, true));
                if (n != null && Projectile.Distance(n.Center) > 100)
                {
                    Vector2 desiredVelocity = Projectile.DirectionTo(n.Center) * desiredFlySpeedInPixelsPerFrame;
                    Projectile.velocity = Vector2.Lerp(Projectile.velocity, desiredVelocity, 1f / amountOfFramesToLerpBy);
                }
                else if (Projectile.velocity.Length() < speed)
                {
                    Projectile.velocity *= 1.04f;
                }
            }
        }
コード例 #7
0
        public override void AI()
        {
            if (projectile.localAI[0] == 0)
            {
                projectile.localAI[0] = 1;
                Main.PlaySound(SoundID.Item8, projectile.Center);
            }
            projectile.rotation += 0.8f / projectile.MaxUpdates;

            /*for (int i = 0; i < 6; i++)
             * {
             *  Vector2 offset = new Vector2(0, -20).RotatedBy(projectile.rotation);
             *  offset = offset.RotatedByRandom(MathHelper.Pi / 6);
             *  int d = Dust.NewDust(projectile.Center, 0, 0, 87, 0f, 0f, 150);
             *  Main.dust[d].position += offset;
             *  float velrando = Main.rand.Next(20, 31) / 10;
             *  Main.dust[d].velocity = projectile.velocity / velrando;
             *  Main.dust[d].noGravity = true;
             * }*/

            if (++projectile.localAI[1] == 30 * projectile.MaxUpdates)
            {
                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 2000));
                if (n == null)
                {
                    projectile.timeLeft = 30 * projectile.MaxUpdates;
                }
                else
                {
                    projectile.velocity = projectile.DirectionTo(n.Center + n.velocity * Main.rand.NextFloat(30)) * 36f;
                }
            }

            projectile.position -= projectile.velocity / projectile.MaxUpdates;
        }
コード例 #8
0
        public override void AI()
        {
            if (Projectile.ai[0] >= 0 && Projectile.ai[0] < Main.maxNPCs)
            {
                int ai0 = (int)Projectile.ai[0];
                if (Main.npc[ai0].CanBeChasedBy())
                {
                    double num4 = (Main.npc[ai0].Center - Projectile.Center).ToRotation() - Projectile.velocity.ToRotation();
                    if (num4 > Math.PI)
                    {
                        num4 -= 2.0 * Math.PI;
                    }
                    if (num4 < -1.0 * Math.PI)
                    {
                        num4 += 2.0 * Math.PI;
                    }
                    Projectile.velocity = Projectile.velocity.RotatedBy(num4 * 0.1f);
                }
                else
                {
                    Projectile.ai[0]     = -1f;
                    Projectile.netUpdate = true;
                }
            }
            else
            {
                if (++Projectile.localAI[1] > 12f)
                {
                    Projectile.localAI[1] = 0f;
                    Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 500, true);
                    Projectile.netUpdate  = true;
                }
            }

            if (++Projectile.localAI[0] >= 24f)
            {
                Projectile.localAI[0] = 0f;
                const int max = 18;
                for (int index1 = 0; index1 < max; ++index1)
                {
                    Vector2 vector2 = (Vector2.UnitX * (float)-Projectile.width / 2f + -Vector2.UnitY.RotatedBy((double)index1 * 2 * 3.14159274101257 / max, new Vector2()) * new Vector2(8f, 16f)).RotatedBy((double)Projectile.rotation - 1.57079637050629, new Vector2());
                    int     index2  = Dust.NewDust(Projectile.Center, 0, 0, 135, 0.0f, 0.0f, 160, new Color(), 1f);
                    Main.dust[index2].scale     = 2f;
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].position  = Projectile.Center + vector2 * 2f;
                    Main.dust[index2].velocity  = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[index2].position) * 1.25f;
                    //Main.dust[index2].velocity *= 2f;
                }
            }
            Vector2 vector21 = Vector2.UnitY.RotatedBy(Projectile.rotation, new Vector2()) * 8f * 2;
            int     index21  = Dust.NewDust(Projectile.Center, 0, 0, 6, 0.0f, 0.0f, 0, new Color(), 1f);

            Main.dust[index21].position  = Projectile.Center + vector21;
            Main.dust[index21].scale     = 1.25f;
            Main.dust[index21].noGravity = true;

            Projectile.rotation = Projectile.velocity.ToRotation() + (float)Math.PI / 2f;
        }
コード例 #9
0
        /*public override void SendExtraAI(BinaryWriter writer)
         * {
         *  writer.Write(modifier);
         * }
         *
         * public override void ReceiveExtraAI(BinaryReader reader)
         * {
         *  modifier = reader.ReadSingle();
         * }*/

        public override void AI()
        {
            /*if (Projectile.localAI[0] == 0)
             * {
             *  Projectile.localAI[0] = 1;
             *
             *  float minionSlotsUsed = 0;
             *  for (int i = 0; i < Main.maxProjectiles; i++)
             *  {
             *      if (Main.Projectile[i].active && !Main.Projectile[i].hostile && Main.Projectile[i].owner == Projectile.owner && Main.Projectile[i].minion)
             *          minionSlotsUsed += Main.Projectile[i].minionSlots;
             *  }
             *
             *  modifier = Main.player[Projectile.owner].maxMinions - minionSlotsUsed;
             *  if (modifier < 0)
             *      modifier = 0;
             *  if (modifier > 3)
             *      modifier = 3;
             *
             *  if (Projectile.owner == Main.myPlayer)
             *  {
             *      Projectile.netUpdate = true;
             *  }
             * }*/

            //dust!
            int dustId = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 2f), Projectile.width, Projectile.height + 5, 60, Projectile.velocity.X * 0.2f,
                                      Projectile.velocity.Y * 0.2f, 100, default(Color), 2f);

            Main.dust[dustId].noGravity = true;
            int dustId3 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y + 2f), Projectile.width, Projectile.height + 5, 60, Projectile.velocity.X * 0.2f,
                                       Projectile.velocity.Y * 0.2f, 100, default(Color), 2f);

            Main.dust[dustId3].noGravity = true;

            const int   aislotHomingCooldown            = 0;
            const int   homingDelay                     = 15;
            const float desiredFlySpeedInPixelsPerFrame = 60;

            float amountOfFramesToLerpBy = 40; //120 - 33 * modifier; // minimum of 1, please keep in full numbers even though it's a float!

            Projectile.ai[aislotHomingCooldown]++;
            if (Projectile.ai[aislotHomingCooldown] > homingDelay)
            {
                Projectile.ai[aislotHomingCooldown] = homingDelay; //cap this value

                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 600, true));
                if (n != null)
                {
                    Vector2 desiredVelocity = Projectile.DirectionTo(n.Center) * desiredFlySpeedInPixelsPerFrame;
                    Projectile.velocity = Vector2.Lerp(Projectile.velocity, desiredVelocity, 1f / amountOfFramesToLerpBy);
                }
            }
        }
コード例 #10
0
        public override void AI()
        {
            const int baseDamage = 100;

            if (projectile.velocity == Vector2.Zero || projectile.velocity.HasNaNs())
            {
                projectile.velocity = -Vector2.UnitY;
            }

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

            projectile.damage = (int)(baseDamage * player.ownedProjectileCounts[projectile.type] * player.magicDamage);
            if (++projectile.ai[0] > 10)
            {
                projectile.ai[0]     = 0;
                projectile.ai[1]     = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 2000);
                projectile.netUpdate = true;
            }

            if (projectile.ai[0] >= 0)
            {
                if (projectile.velocity.Length() < 24)
                {
                    projectile.velocity *= 1.06f;
                }
            }

            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[1]);

            if (npc != null)
            {
                double num4 = (npc.Center - projectile.Center).ToRotation() - projectile.velocity.ToRotation();
                if (num4 > Math.PI)
                {
                    num4 -= 2.0 * Math.PI;
                }
                if (num4 < -1.0 * Math.PI)
                {
                    num4 += 2.0 * Math.PI;
                }
                projectile.velocity = projectile.velocity.RotatedBy(num4 * 0.2f);
            }
            else
            {
                projectile.ai[1]     = -1f;
                projectile.netUpdate = true;
            }

            projectile.direction = projectile.spriteDirection = projectile.velocity.X < 0 ? -1 : 1;
            projectile.rotation += projectile.spriteDirection * 1f;
        }
コード例 #11
0
        public override void AI()
        {
            float rand = Main.rand.Next(90, 111) * 0.01f * (Main.essScale * 0.5f);

            Lighting.AddLight(Projectile.Center, 0.5f * rand, 0.1f * rand, 0.1f * rand);

            if (Projectile.localAI[0] == 0)
            {
                Projectile.localAI[0] = 1;
                Projectile.ai[0]      = -1;
            }

            if (Projectile.ai[0] >= 0 && Projectile.ai[0] < Main.maxNPCs)
            {
                int ai0 = (int)Projectile.ai[0];
                if (Main.npc[ai0].CanBeChasedBy() && Projectile.Distance(Main.npc[ai0].Center) > Math.Min(Main.npc[ai0].height, Main.npc[ai0].width) / 2)
                {
                    double num4 = (Main.npc[ai0].Center - Projectile.Center).ToRotation() - Projectile.velocity.ToRotation();
                    if (num4 > Math.PI)
                    {
                        num4 -= 2.0 * Math.PI;
                    }

                    if (num4 < -1.0 * Math.PI)
                    {
                        num4 += 2.0 * Math.PI;
                    }

                    Projectile.velocity = Projectile.velocity.RotatedBy(num4 * 0.3f);
                }
                else
                {
                    Projectile.ai[0]     = -1f;
                    Projectile.ai[1]     = 18f;
                    Projectile.netUpdate = true;
                }
            }
            else
            {
                if (--Projectile.ai[1] < 0f)
                {
                    Projectile.ai[1]     = 18f;
                    Projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1700f);
                    Projectile.netUpdate = true;
                }
            }

            Projectile.rotation = Projectile.velocity.ToRotation() - (float)Math.PI / 2;
        }
コード例 #12
0
        public override void AI()
        {
            if (Projectile.velocity.Length() < 32f) //accelerate over time
            {
                Projectile.velocity = Vector2.Normalize(Projectile.velocity) * (Projectile.velocity.Length() + 32f / 300f);
            }

            NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[0]);

            if (npc != null)
            {
                Projectile.velocity = Projectile.DirectionTo(npc.Center) * Projectile.velocity.Length();
            }
            else
            {
                if (++Projectile.localAI[0] > 6f)
                {
                    Projectile.localAI[0] = 1f;
                    Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1500);
                    Projectile.netUpdate  = true;
                }
            }

            if (Projectile.localAI[1] == 0)
            {
                Projectile.localAI[1] = 1;
                SoundEngine.PlaySound(SoundID.Item14, Projectile.Center);
            }

            int index2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool() ? 174 : 259, 0f, 0f, 100, new Color(), 2f);

            Main.dust[index2].noGravity = true;
            Main.dust[index2].velocity *= 3;
            int index3 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool() ? 174 : 259, 0f, 0f, 100, new Color(), 1f);

            Main.dust[index3].velocity *= 2f;
            Main.dust[index3].noGravity = true;

            Projectile.rotation += 0.4f;

            if (++Projectile.frameCounter > 3)
            {
                Projectile.frameCounter = 0;
                if (++Projectile.frame >= Main.projFrames[Projectile.type])
                {
                    Projectile.frame = 0;
                }
            }
        }
コード例 #13
0
        public override void AI()
        {
            if (projectile.localAI[0] == 0f)
            {
                Terraria.Audio.SoundEngine.PlaySound(SoundID.Item20, projectile.position);
                projectile.localAI[0] = 1f;
                projectile.ai[1]      = -1f;
            }

            int dust = Dust.NewDust(projectile.Center, 0, 0, 66, 0f, 0f, 100, new Color(244, 66, 113), 1f);

            Main.dust[dust].velocity *= 0.1f;
            if (projectile.velocity == Vector2.Zero)
            {
                Main.dust[dust].velocity.Y -= 1f;
                Main.dust[dust].scale       = 1.2f;
            }
            else
            {
                Main.dust[dust].velocity += projectile.velocity * 0.2f;
            }

            /*Main.dust[dust].position.X = projectile.Center.X + 4f + Main.rand.Next(-2, 3);
             * Main.dust[dust].position.Y = projectile.Center.Y + Main.rand.Next(-2, 3);*/
            Main.dust[dust].noGravity = true;

            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[1]);

            if (npc != null) //has target
            {
                float   rotation    = projectile.velocity.ToRotation();
                Vector2 vel         = npc.Center - projectile.Center;
                float   targetAngle = vel.ToRotation();
                projectile.velocity = new Vector2(projectile.velocity.Length(), 0f).RotatedBy(rotation.AngleLerp(targetAngle, 0.008f));
            }
            else //currently has no target
            {
                if (--projectile.localAI[1] < 0)
                {
                    projectile.localAI[1] = 10;
                    projectile.ai[1]      = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 2000);
                    if (projectile.ai[1] != -1)
                    {
                        projectile.netUpdate = true;
                    }
                }
            }
        }
コード例 #14
0
        public override void AI()
        {
            //dust!

            /*int dustId = Dust.NewDust(Projectile.position, Projectile.width / 2, Projectile.height + 5, 56, Projectile.velocity.X * 0.2f,
             *  Projectile.velocity.Y * 0.2f, 100, default(Color), .5f);
             * Main.dust[dustId].noGravity = true;
             * int dustId3 = Dust.NewDust(Projectile.position, Projectile.width / 2, Projectile.height + 5, 56, Projectile.velocity.X * 0.2f,
             *  Projectile.velocity.Y * 0.2f, 100, default(Color), .5f);
             * Main.dust[dustId3].noGravity = true;*/

            Projectile.hide = false;

            if (++Projectile.localAI[0] == 20)
            {
                Projectile.localAI[0] = 0;

                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1500));
                if (n == null)
                {
                    Projectile.Kill();
                }
                else
                {
                    Projectile.velocity = Projectile.DirectionTo(n.Center + n.velocity * 10) * 32f;
                }
            }

            if (Projectile.alpha > 0)
            {
                Projectile.alpha -= 20;
                if (Projectile.alpha < 0)
                {
                    Projectile.alpha = 0;
                }
            }
            Projectile.scale = (1f - Projectile.alpha / 255f) * .75f;
            if (++Projectile.frameCounter >= 6)
            {
                Projectile.frameCounter = 0;
                if (++Projectile.frame > 1)
                {
                    Projectile.frame = 0;
                }
            }
        }
コード例 #15
0
        public override void AI()
        {
            //dust!

            /*int dustId = Dust.NewDust(projectile.position, projectile.width / 2, projectile.height + 5, 56, projectile.velocity.X * 0.2f,
             *  projectile.velocity.Y * 0.2f, 100, default(Color), .5f);
             * Main.dust[dustId].noGravity = true;
             * int dustId3 = Dust.NewDust(projectile.position, projectile.width / 2, projectile.height + 5, 56, projectile.velocity.X * 0.2f,
             *  projectile.velocity.Y * 0.2f, 100, default(Color), .5f);
             * Main.dust[dustId3].noGravity = true;*/

            if (++projectile.localAI[0] == 20)
            {
                //projectile.localAI[0] = 0;

                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 1500));
                if (n == null)
                {
                    projectile.Kill();
                }
                else
                {
                    projectile.velocity = projectile.DirectionTo(n.Center + n.velocity * Main.rand.NextFloat(60)) * 32f;
                }
            }

            if (projectile.alpha > 0)
            {
                projectile.alpha -= 20;
                if (projectile.alpha < 0)
                {
                    projectile.alpha = 0;
                }
            }
            projectile.scale = 1f - projectile.alpha / 255f;
            if (++projectile.frameCounter >= 6)
            {
                projectile.frameCounter = 0;
                if (++projectile.frame > 1)
                {
                    projectile.frame = 0;
                }
            }
        }
コード例 #16
0
        public override void AI()
        {
            if (projectile.localAI[0] == 0)
            {
                projectile.localAI[0] = 1;
                projectile.ai[0]      = -1; //for homing
            }

            const int   homingDelay = 20;
            const float desiredFlySpeedInPixelsPerFrame = 60;
            const float amountOfFramesToLerpBy          = 30; // minimum of 1, please keep in full numbers even though it's a float!

            if (projectile.ai[0] == -1)                       //no target atm
            {
                if (++projectile.ai[1] > homingDelay)
                {
                    projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 600, true);
                    projectile.ai[1]     = 0;
                    projectile.netUpdate = true;
                }
            }
            else //currently have target
            {
                NPC npc = Main.npc[(int)projectile.ai[0]];

                if (npc.active && npc.CanBeChasedBy()) //target is still valid
                {
                    Vector2 desiredVelocity = projectile.DirectionTo(npc.Center) * desiredFlySpeedInPixelsPerFrame;
                    projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / amountOfFramesToLerpBy);
                }
                else //target lost, reset
                {
                    projectile.ai[0]     = -1;
                    projectile.ai[1]     = 0;
                    projectile.netUpdate = true;
                }
            }

            projectile.rotation += 0.3f * Math.Sign(projectile.velocity.X);
        }
コード例 #17
0
        public override void AI()
        {
            Projectile.rotation += 0.2f;

            const int   aislotHomingCooldown            = 0;
            int         homingDelay                     = (int)Projectile.ai[1];
            const float desiredFlySpeedInPixelsPerFrame = 45;
            const float amountOfFramesToLerpBy          = 15; // minimum of 1, please keep in full numbers even though it's  float!

            Projectile.ai[aislotHomingCooldown]++;
            if (Projectile.ai[aislotHomingCooldown] > homingDelay)
            {
                Projectile.ai[aislotHomingCooldown] = homingDelay; //cap this value

                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1000));
                if (n != null)
                {
                    Vector2 desiredVelocity = Projectile.DirectionTo(n.Center) * desiredFlySpeedInPixelsPerFrame;
                    Projectile.velocity = Vector2.Lerp(Projectile.velocity, desiredVelocity, 1f / amountOfFramesToLerpBy);
                }
            }
        }
コード例 #18
0
        public override void AI()
        {
            Projectile.scale = 2f;

            if (Projectile.ai[1] == 0)
            {
                Projectile.ai[1] = 1;

                const int num226 = 12;
                for (int i = 0; i < num226; i++)
                {
                    Vector2 vector6 = Vector2.UnitX.RotatedBy(Projectile.rotation) * 6f;
                    vector6 = vector6.RotatedBy(((i - (num226 / 2 - 1)) * 6.28318548f / num226), default(Vector2)) + Projectile.Center;
                    Vector2 vector7 = vector6 - Projectile.Center;
                    int     num228  = Dust.NewDust(vector6 + vector7, 0, 0, DustID.FlameBurst, 0f, 0f, 0, default(Color), 1.5f);
                    Main.dust[num228].noGravity = true;
                    Main.dust[num228].velocity  = vector7;
                }
            }

            const int   aislotHomingCooldown            = 0;
            const int   homingDelay                     = 0;
            const float desiredFlySpeedInPixelsPerFrame = 8;
            const float amountOfFramesToLerpBy          = 25; // minimum of 1, please keep in full numbers even though it's a float!

            Projectile.ai[aislotHomingCooldown]++;
            if (Projectile.ai[aislotHomingCooldown] > homingDelay)
            {
                Projectile.ai[aislotHomingCooldown] = homingDelay; //cap this value

                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1000));
                if (n != null)
                {
                    Vector2 desiredVelocity = Projectile.DirectionTo(n.Center) * desiredFlySpeedInPixelsPerFrame;
                    Projectile.velocity = Vector2.Lerp(Projectile.velocity, desiredVelocity, 1f / amountOfFramesToLerpBy);
                }
            }
        }
コード例 #19
0
        public override void AI()
        {
            projectile.rotation = projectile.velocity.ToRotation() - MathHelper.Pi;
            Counter++;

            const int   aislotHomingCooldown            = 0;
            const int   homingDelay                     = 30;
            const float desiredFlySpeedInPixelsPerFrame = 30;
            const float amountOfFramesToLerpBy          = 30; // minimum of 1, please keep in full numbers even though it's a float!

            projectile.ai[aislotHomingCooldown]++;
            if (projectile.ai[aislotHomingCooldown] > homingDelay)
            {
                projectile.ai[aislotHomingCooldown] = homingDelay; //cap this value

                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 1000));
                if (n != null)
                {
                    Vector2 desiredVelocity = projectile.DirectionTo(n.Center) * desiredFlySpeedInPixelsPerFrame;
                    projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / amountOfFramesToLerpBy);
                }
            }
        }
コード例 #20
0
        public override void AI()
        {
            const int   aislotHomingCooldown            = 0;
            const int   homingDelay                     = 0;
            const float desiredFlySpeedInPixelsPerFrame = 45;
            const float amountOfFramesToLerpBy          = 5; // minimum of 1, please keep in full numbers even though it's a float!

            projectile.ai[aislotHomingCooldown]++;
            if (projectile.ai[aislotHomingCooldown] > homingDelay)
            {
                projectile.ai[aislotHomingCooldown] = homingDelay; //cap this value

                NPC n = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 2000));
                if (n != null)
                {
                    if (projectile.Distance(n.Center) > Math.Max(n.width, n.height))
                    {
                        Vector2 desiredVelocity = projectile.DirectionTo(n.Center) * desiredFlySpeedInPixelsPerFrame;
                        projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / amountOfFramesToLerpBy);
                    }
                }
            }
        }
コード例 #21
0
        public override void AI()
        {
            if (Projectile.localAI[1] == 0f)
            {
                Projectile.localAI[1] = Projectile.ai[1] + 1;

                //SoundEngine.PlaySound(new SoundStyle("Terraria/Sounds/Zombie_20"), Projectile.Center);
                SoundEngine.PlaySound(SoundID.ForceRoarPitched, Projectile.Center);

                /*switch ((int)Projectile.ai[1])
                 * {
                 *  case 1: Projectile.DamageType = DamageClass.Melee; break;
                 *  case 2: Projectile.DamageType = DamageClass.Ranged; break;
                 *  case 3: Projectile.DamageType = DamageClass.Magic; break;
                 *  case 4: Projectile.DamageType = DamageClass.Summon; break;
                 *  case 5: Projectile.DamageType = DamageClass.Throwing; break;
                 *  default: break;
                 * }*/
                Projectile.ai[1]     = 0f;
                Projectile.netUpdate = true;
            }

            if (Projectile.localAI[0]++ > 30f)
            {
                Projectile.localAI[0] = 0f;
                Projectile.ai[1]++;
            }

            if (Projectile.ai[1] % 2 == 1) //dash
            {
                //Projectile.rotation = Projectile.velocity.ToRotation();
                Projectile.direction = Projectile.spriteDirection = Projectile.velocity.X > 0 ? 1 : -1;

                /*Projectile.frameCounter = 5;
                 * Projectile.frame = 6;*/

                int num22 = 7;
                for (int index1 = 0; index1 < num22; ++index1)
                {
                    Vector2 vector2_1 = (Vector2.Normalize(Projectile.velocity) * new Vector2((Projectile.width + 50) / 2f, Projectile.height) * 0.75f).RotatedBy((index1 - (num22 / 2 - 1)) * Math.PI / num22, new Vector2()) + Projectile.Center;
                    Vector2 vector2_2 = ((float)(Main.rand.NextDouble() * 3.14159274101257) - 1.570796f).ToRotationVector2() * Main.rand.Next(3, 8);
                    Vector2 vector2_3 = vector2_2;
                    int     index2    = Dust.NewDust(vector2_1 + vector2_3, 0, 0, DustID.Shadowflame, vector2_2.X * 2f, vector2_2.Y * 2f, 100, new Color(), 1.4f);
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].noLight   = true;
                    Main.dust[index2].velocity /= 4f;
                    Main.dust[index2].velocity -= Projectile.velocity;
                }
            }
            else //preparing to dash
            {
                int         ai0       = (int)Projectile.ai[0];
                const float moveSpeed = 1f;
                if (Projectile.localAI[0] == 30f)                               //just about to dash
                {
                    if (Projectile.ai[0] >= 0 && Main.npc[ai0].CanBeChasedBy()) //has target
                    {
                        Projectile.velocity = Main.npc[ai0].Center - Projectile.Center;
                        Projectile.velocity.Normalize();
                        Projectile.velocity *= 27f;
                        //Projectile.rotation = Projectile.velocity.ToRotation();
                        Projectile.direction = Projectile.spriteDirection = Projectile.velocity.X > 0 ? 1 : -1;

                        /*Projectile.frameCounter = 5;
                         * Projectile.frame = 6;*/
                    }
                    else //no target
                    {
                        Projectile.localAI[0] = -1f;
                        Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1000);
                        Projectile.netUpdate  = true;

                        /*if (++Projectile.frameCounter > 5)
                         * {
                         *  Projectile.frameCounter = 0;
                         *  if (++Projectile.frame > 5)
                         *      Projectile.frame = 0;
                         * }*/
                    }
                }
                else //regular movement
                {
                    if (Projectile.ai[0] >= 0 && Main.npc[ai0].CanBeChasedBy()) //has target
                    {
                        Vector2 vel = Main.npc[ai0].Center - Projectile.Center;
                        //Projectile.rotation = vel.ToRotation();
                        if (vel.X > 0) //projectile is on left side of target
                        {
                            vel.X -= 300;
                            Projectile.direction = Projectile.spriteDirection = 1;
                        }
                        else //projectile is on right side of target
                        {
                            vel.X += 300;
                            Projectile.direction = Projectile.spriteDirection = -1;
                        }
                        vel.Y -= 200f;
                        vel.Normalize();
                        vel *= 12f;
                        if (Projectile.velocity.X < vel.X)
                        {
                            Projectile.velocity.X += moveSpeed;
                            if (Projectile.velocity.X < 0 && vel.X > 0)
                            {
                                Projectile.velocity.X += moveSpeed;
                            }
                        }
                        else if (Projectile.velocity.X > vel.X)
                        {
                            Projectile.velocity.X -= moveSpeed;
                            if (Projectile.velocity.X > 0 && vel.X < 0)
                            {
                                Projectile.velocity.X -= moveSpeed;
                            }
                        }
                        if (Projectile.velocity.Y < vel.Y)
                        {
                            Projectile.velocity.Y += moveSpeed;
                            if (Projectile.velocity.Y < 0 && vel.Y > 0)
                            {
                                Projectile.velocity.Y += moveSpeed;
                            }
                        }
                        else if (Projectile.velocity.Y > vel.Y)
                        {
                            Projectile.velocity.Y -= moveSpeed;
                            if (Projectile.velocity.Y > 0 && vel.Y < 0)
                            {
                                Projectile.velocity.Y -= moveSpeed;
                            }
                        }
                    }
                    else //no target
                    {
                        if (Projectile.velocity.X < -1f)
                        {
                            Projectile.velocity.X += moveSpeed;
                        }
                        else if (Projectile.velocity.X > 1f)
                        {
                            Projectile.velocity.X -= moveSpeed;
                        }
                        if (Projectile.velocity.Y > -8f)
                        {
                            Projectile.velocity.Y -= moveSpeed;
                        }
                        else if (Projectile.velocity.Y < -10f)
                        {
                            Projectile.velocity.Y += moveSpeed;
                        }
                        Projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1000);
                        Projectile.netUpdate = true;
                    }

                    /*if (++Projectile.frameCounter > 5)
                     * {
                     *  Projectile.frameCounter = 0;
                     *  if (++Projectile.frame > 5)
                     *      Projectile.frame = 0;
                     * }*/
                }
            }
            Projectile.position += Projectile.velocity / 4f;

            if (++Projectile.frameCounter > 4)
            {
                Projectile.frameCounter = 0;
                if (++Projectile.frame >= 4)
                {
                    Projectile.frame = 0;
                }
            }

            ringRotation   += rotationPerTick;
            scytheRotation += 0.5f;
        }
コード例 #22
0
        public override bool PreAI()
        {
            Player player = Main.player[Projectile.owner];

            if (player.dead || !player.active)
            {
                player.ClearBuff(ModContent.BuffType <JungleMimicSummonBuff>());
            }

            if (player.HasBuff(ModContent.BuffType <JungleMimicSummonBuff>()))
            {
                Projectile.timeLeft = 2;
            }

            counter++;
            if (counter % 15 == 0)
            {
                if (Projectile.owner == Main.myPlayer)
                {
                    NPC targetNPC = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1000, true));
                    if (targetNPC != null)
                    {
                        Vector2 shootVel = Projectile.DirectionTo(targetNPC.Center);
                        SoundEngine.PlaySound(SoundID.Item11, Projectile.Center);
                        FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, shootVel * 14f + targetNPC.velocity / 2, ModContent.ProjectileType <JungleMimicSummonCoin>(), Projectile.originalDamage / 4, Projectile.knockBack, Main.myPlayer);
                    }
                }
            }

            if (counter > 180)
            {
                if (counter > 300)
                {
                    counter = 0;
                }

                if (Projectile.owner == Main.myPlayer)
                {
                    NPC targetNPC = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1000, true));
                    if (targetNPC != null)
                    {
                        Projectile.frameCounter++;
                        trailbehind = true;
                        if (Projectile.frameCounter > 8)
                        {
                            Projectile.frame++;
                            if (Projectile.frame > 5)
                            {
                                Projectile.frame = 2;
                            }
                        }

                        for (int index = 0; index < 1000; ++index)
                        {
                            if (index != Projectile.whoAmI && Main.projectile[index].active && (Main.projectile[index].owner == Projectile.owner && Main.projectile[index].type == Projectile.type) && (double)Math.Abs((float)(Projectile.position.X - Main.projectile[index].position.X)) + (double)Math.Abs((float)(Projectile.position.Y - Main.projectile[index].position.Y)) < (double)Projectile.width)
                            {
                                if (Projectile.position.X < Main.projectile[index].position.X)
                                {
                                    Projectile.velocity.X -= 0.05f;
                                }
                                else
                                {
                                    Projectile.velocity.X += 0.05f;
                                }
                                if (Projectile.position.Y < Main.projectile[index].position.Y)
                                {
                                    Projectile.velocity.Y -= 0.05f;
                                }
                                else
                                {
                                    Projectile.velocity.Y += 0.05f;
                                }
                            }
                        }

                        Vector2 dashVel = Projectile.DirectionTo(targetNPC.Center);
                        Projectile.velocity        = Vector2.Lerp(Projectile.velocity, dashVel * 18, 0.03f);
                        Projectile.rotation        = 0;
                        Projectile.tileCollide     = false;
                        Projectile.direction       = Math.Sign(Projectile.velocity.X);
                        Projectile.spriteDirection = -Projectile.direction;
                        return(false);
                    }
                }
            }
            trailbehind            = false;
            Projectile.tileCollide = true;
            return(true);
        }
コード例 #23
0
        public override void AI()
        {
            if (projectile.localAI[0] == 0)
            {
                projectile.localAI[0] = Main.rand.NextFloat(0.25f, 2f); //used for random variation in homing
                projectile.rotation   = Main.rand.NextFloat(MathHelper.TwoPi);
            }

            if (projectile.timeLeft > 120)
            {
                projectile.timeLeft = 120;
            }
            projectile.ai[1]++;
            projectile.scale = 1f + projectile.ai[1] / 80;

            projectile.rotation += 0.3f * projectile.direction;

            projectile.frameCounter++;
            if (projectile.frameCounter > 17)
            {
                projectile.frame++;
                projectile.frameCounter = 0;
            }

            if (projectile.frame > 6)
            {
                projectile.Kill();
            }

            if (projectile.frame > 4)
            {
                projectile.alpha = 155;
                return;
            }

            if (targetID == -1)       //no target atm
            {
                if (searchTimer == 0) //search every 18/3=6 ticks
                {
                    searchTimer          = 18;
                    targetID             = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 300);
                    projectile.netUpdate = true;
                }
                searchTimer--;
            }
            else //currently have target
            {
                NPC npc = Main.npc[targetID];

                if (npc.active && npc.CanBeChasedBy()) //target is still valid
                {
                    Vector2 distance = npc.Center - projectile.Center;
                    double  angle    = distance.ToRotation() - projectile.velocity.ToRotation();
                    if (angle > Math.PI)
                    {
                        angle -= 2.0 * Math.PI;
                    }
                    if (angle < -Math.PI)
                    {
                        angle += 2.0 * Math.PI;
                    }

                    if (projectile.ai[0] == -1)
                    {
                        if (Math.Abs(angle) > Math.PI * 0.75)
                        {
                            projectile.velocity = projectile.velocity.RotatedBy(angle * 0.07 * projectile.localAI[0]);
                        }
                        else
                        {
                            float range      = distance.Length();
                            float difference = 12.7f / range;
                            distance            *= difference;
                            distance            /= 7f;
                            projectile.velocity += distance;
                            if (range > 70f)
                            {
                                projectile.velocity *= 0.977f;
                            }
                        }
                    }
                    else
                    {
                        projectile.velocity = projectile.velocity.RotatedBy(angle * 0.1 * projectile.localAI[0]);
                    }
                }
                else //target lost, reset
                {
                    targetID             = -1;
                    searchTimer          = 0;
                    projectile.netUpdate = true;
                }
            }
        }
コード例 #24
0
        public override void AI()
        {
            if (Main.player[projectile.owner].active && !Main.player[projectile.owner].dead && Main.player[projectile.owner].GetModPlayer <FargoPlayer>().EridanusEmpower)
            {
                projectile.timeLeft = 2;
            }
            else
            {
                projectile.Kill();
                return;
            }

            projectile.damage = (int)(baseDamage * Main.player[projectile.owner].minionDamage);

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

            NPC minionAttackTargetNpc = projectile.OwnerMinionAttackTargetNPC;

            if (minionAttackTargetNpc != null && projectile.ai[0] != minionAttackTargetNpc.whoAmI && minionAttackTargetNpc.CanBeChasedBy(projectile))
            {
                projectile.ai[0]     = minionAttackTargetNpc.whoAmI;
                projectile.netUpdate = true;
            }

            if (++projectile.frameCounter > 6)
            {
                projectile.frameCounter = 0;
                projectile.frame++;
            }
            if (projectile.frame > 4)
            {
                projectile.frame = 0;
            }

            projectile.rotation = 0;

            if (projectile.ai[0] >= 0 && projectile.ai[0] < Main.maxNPCs) //has target
            {
                NPC npc = Main.npc[(int)projectile.ai[0]];

                if (npc.CanBeChasedBy(projectile) && player.Distance(projectile.Center) < 2500 && projectile.Distance(npc.Center) < 2500)
                {
                    projectile.direction = projectile.spriteDirection = projectile.Center.X < npc.Center.X ? 1 : -1;

                    switch (player.GetModPlayer <FargoPlayer>().EridanusTimer / (60 * 10)) //attack according to current class
                    {
                    case 0:                                                                //melee
                    {
                        float length = player.Distance(npc.Center) - 300;
                        if (length > 300)
                        {
                            length = 300;
                        }
                        Vector2 home = player.Center + player.DirectionTo(npc.Center) * length;
                        projectile.Center    = Vector2.Lerp(projectile.Center, home, 0.15f);
                        projectile.velocity *= 0.8f;

                        if (++projectile.localAI[0] > 5)         //spam close range fists
                        {
                            projectile.localAI[0] = 0;
                            if (Main.myPlayer == projectile.owner && player.HeldItem.melee)
                            {
                                const float maxRange = 700;
                                Projectile.NewProjectile(projectile.Center + projectile.DirectionTo(npc.Center) * 40, 16f * projectile.DirectionTo(npc.Center).RotatedByRandom(MathHelper.ToRadians(15)),
                                                         ModContent.ProjectileType <EridanusFist>(), (int)(baseDamage * Main.player[projectile.owner].meleeDamage / 3), projectile.knockBack / 2, Main.myPlayer, maxRange);
                            }
                        }

                        projectile.frame    = player.HeldItem.melee ? 6 : 5;
                        projectile.rotation = projectile.DirectionTo(npc.Center).ToRotation();
                        if (projectile.spriteDirection < 0)
                        {
                            projectile.rotation += (float)Math.PI;
                        }
                    }
                    break;

                    case 1:     //ranged
                    {
                        Vector2 home = player.Center;
                        home.X              -= 50 * player.direction;
                        home.Y              -= 40;
                        projectile.Center    = Vector2.Lerp(projectile.Center, home, 0.15f);
                        projectile.velocity *= 0.8f;

                        if (++projectile.localAI[0] > 65)         //shoot giant homing bullet
                        {
                            projectile.localAI[0] = 0;
                            if (Main.myPlayer == projectile.owner && player.HeldItem.ranged)
                            {
                                Projectile.NewProjectile(projectile.Center, 12f * projectile.DirectionTo(npc.Center), ModContent.ProjectileType <EridanusBullet>(),
                                                         (int)(baseDamage * Main.player[projectile.owner].rangedDamage * 1.5f), projectile.knockBack * 2, Main.myPlayer, npc.whoAmI);
                            }
                        }

                        if (player.HeldItem.ranged)
                        {
                            if (projectile.localAI[0] < 15)
                            {
                                projectile.frame = 8;
                            }
                            else if (projectile.localAI[0] > 50)
                            {
                                projectile.frame = 7;
                            }
                        }
                    }
                    break;

                    case 2:     //magic
                    {
                        Vector2 home = player.Center + (npc.Center - player.Center) / 3;
                        projectile.Center    = Vector2.Lerp(projectile.Center, home, 0.15f);
                        projectile.velocity *= 0.8f;

                        if (player.HeldItem.magic && projectile.localAI[0] > 45)
                        {
                            projectile.frame = 7;
                        }

                        if (++projectile.localAI[0] > 60)
                        {
                            if (projectile.localAI[0] > 90)
                            {
                                projectile.localAI[0] = 0;
                            }

                            if (player.HeldItem.magic)
                            {
                                projectile.frame = 8;
                            }

                            if (projectile.localAI[0] % 5 == 0 && player.HeldItem.magic)         //rain lunar flares
                            {
                                Main.PlaySound(SoundID.Item88, projectile.Center);

                                if (Main.myPlayer == projectile.owner)
                                {
                                    Vector2 spawnPos = projectile.Center;
                                    spawnPos.X += Main.rand.NextFloat(-250, 250);
                                    spawnPos.Y -= 600f;

                                    Vector2 vel = 10f * npc.DirectionFrom(spawnPos);

                                    spawnPos += npc.velocity * Main.rand.NextFloat(10f);

                                    Projectile.NewProjectile(spawnPos, vel, ProjectileID.LunarFlare,
                                                             (int)(baseDamage * player.magicDamage / 2), projectile.knockBack / 2, Main.myPlayer, 0, npc.Center.Y);
                                }
                            }
                        }
                    }
                    break;

                    default:     //minion
                    {
                        Vector2 home = npc.Center;
                        home.X += 350 * Math.Sign(player.Center.X - npc.Center.X);
                        if (projectile.Distance(home) > 50)
                        {
                            Movement(home, 0.8f, 32f);
                        }

                        projectile.frame = 5;

                        bool okToAttack = (!player.HeldItem.melee && !player.HeldItem.ranged && !player.HeldItem.magic) || !player.controlUseItem;

                        if (++projectile.localAI[0] > 15)
                        {
                            projectile.localAI[0] = 0;
                            if (Main.myPlayer == projectile.owner && okToAttack)
                            {
                                int modifier = Math.Sign(projectile.Center.Y - npc.Center.Y);
                                Projectile.NewProjectile(projectile.Center + 3000 * projectile.DirectionFrom(npc.Center) * modifier,
                                                         projectile.DirectionTo(npc.Center) * modifier, ModContent.ProjectileType <EridanusDeathray>(),
                                                         projectile.damage, projectile.knockBack / 4, Main.myPlayer);
                            }
                        }

                        if (okToAttack && projectile.localAI[0] < 7)
                        {
                            projectile.frame = 6;
                        }

                        projectile.rotation = projectile.DirectionTo(npc.Center).ToRotation();
                        if (projectile.spriteDirection < 0)
                        {
                            projectile.rotation += (float)Math.PI;
                        }
                    }
                    break;
                    }
                }
                else //forget target
                {
                    projectile.ai[0]      = -1f;
                    projectile.localAI[0] = 0f;
                    projectile.netUpdate  = true;
                }
            }
            else //no target
            {
                projectile.localAI[0] = 0f;

                Vector2 home = player.Center;
                home.X -= 50 * player.direction;
                home.Y -= 40;

                projectile.direction = projectile.spriteDirection = player.direction;

                if (projectile.Distance(home) > 2000f)
                {
                    projectile.Center   = player.Center;
                    projectile.velocity = Vector2.Zero;
                }
                else
                {
                    projectile.Center    = Vector2.Lerp(projectile.Center, home, 0.25f);
                    projectile.velocity *= 0.8f;
                }

                if (++projectile.localAI[1] > 6f)
                {
                    projectile.localAI[1] = 0f;
                    projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 1500);
                    projectile.netUpdate  = true;
                }
            }

            if (++drawTrailOffset > 2)
            {
                drawTrailOffset = 0;
            }
        }
コード例 #25
0
        public override void AI()
        {
            Player           player    = Main.player[Projectile.owner];
            FargoSoulsPlayer modPlayer = player.GetModPlayer <FargoSoulsPlayer>();

            if (player.dead)
            {
                modPlayer.BrainMinion = false;
            }
            if (modPlayer.BrainMinion)
            {
                Projectile.timeLeft = 2;
            }

            int Brain = -1;

            for (int i = 0; i < Main.projectile.Length; i++)
            {
                if (Main.projectile[i].type == ModContent.ProjectileType <BrainMinion>() && Main.projectile[i].active && Main.projectile[i].owner == Projectile.owner)
                {
                    Brain = i;
                }
            }
            if (Brain == -1)
            {
                Projectile.Kill();
            }
            else
            {
                for (int index = 0; index < 1000; ++index)
                {
                    if (index != Projectile.whoAmI && Main.projectile[index].active && (Main.projectile[index].owner == Projectile.owner && Main.projectile[index].type == Projectile.type) && (double)Math.Abs((float)(Projectile.position.X - Main.projectile[index].position.X)) + (double)Math.Abs((float)(Projectile.position.Y - Main.projectile[index].position.Y)) < (double)Projectile.width)
                    {
                        if (Projectile.position.X < Main.projectile[index].position.X)
                        {
                            Projectile.velocity.X -= 0.2f;
                        }
                        else
                        {
                            Projectile.velocity.X += 0.2f;
                        }
                        if (Projectile.position.Y < Main.projectile[index].position.Y)
                        {
                            Projectile.velocity.Y -= 0.2f;
                        }
                        else
                        {
                            Projectile.velocity.Y += 0.2f;
                        }
                    }
                }

                NPC  targetnpc  = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 1000, true));
                bool targetting = targetnpc != null;
                if (!targetting || Projectile.ai[0] > 0)
                {
                    float movespeed = Math.Max(Projectile.Distance(Main.projectile[Brain].Center) / 40f, 10f);

                    Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.DirectionTo(Main.projectile[Brain].Center) * movespeed, 0.04f);
                    if (Projectile.Hitbox.Intersects(Main.projectile[Brain].Hitbox))
                    {
                        Projectile.ai[0] = 0;
                    }
                }
                if (targetting && Projectile.ai[0] == 0)
                {
                    float movespeed = Math.Max(Projectile.Distance(targetnpc.Center) / 40f, 14f);

                    Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.DirectionTo(targetnpc.Center) * movespeed, 0.05f);
                }
            }
        }
コード例 #26
0
        public override void AI()
        {
            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[1]);

            if (npc != null)
            {
                if (npc.CanBeChasedBy(projectile))
                {
                    float   rotation = projectile.velocity.ToRotation();
                    Vector2 vel      = npc.Center - projectile.Center;
                    if (vel.Length() < 20f)
                    {
                        projectile.Kill();
                        return;
                    }
                    float targetAngle = vel.ToRotation();
                    projectile.velocity = new Vector2(projectile.velocity.Length(), 0f).RotatedBy(rotation.AngleLerp(targetAngle, 0.008f + 0.08f * Math.Min(1f, projectile.ai[0] / 180)));

                    if (projectile.timeLeft % projectile.MaxUpdates == 0)
                    {
                        projectile.ai[0]++;
                    }
                }
                else
                {
                    projectile.ai[1] = -1f;
                }
            }
            else if (projectile.localAI[0] == 0f) //also used for dust timer btw
            {
                projectile.ai[1]     = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 1000, true);
                projectile.netUpdate = true;
            }

            projectile.alpha -= 40;
            if (projectile.alpha < 0)
            {
                projectile.alpha = 0;
            }

            projectile.frameCounter++;
            if (projectile.frameCounter > 2)
            {
                projectile.frameCounter = 0;
                projectile.frame++;
                if (projectile.frame > 3)
                {
                    projectile.frame = 0;
                }
            }

            Lighting.AddLight(projectile.Center, 1.1f, 0.9f, 0.4f);
            projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2;

            ++projectile.localAI[0];
            if ((double)projectile.localAI[0] == 12.0) //loads of vanilla dust :echprime:
            {
                projectile.localAI[0] = 0.0f;
                for (int index1 = 0; index1 < 12; ++index1)
                {
                    Vector2 vector2 = (Vector2.UnitX * (float)-projectile.width / 2f + -Vector2.UnitY.RotatedBy((double)index1 * 3.14159274101257 / 6.0, new Vector2()) * new Vector2(8f, 16f)).RotatedBy((double)projectile.rotation - 1.57079637050629, new Vector2());
                    int     index2  = Dust.NewDust(projectile.Center, 0, 0, 6, 0.0f, 0.0f, 160, new Color(), 1f);
                    Main.dust[index2].scale     = 1.1f;
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].position  = projectile.Center + vector2;
                    Main.dust[index2].velocity  = projectile.velocity * 0.1f;
                    Main.dust[index2].velocity  = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[index2].position) * 1.25f;
                }
            }
            if (Main.rand.NextBool(4))
            {
                for (int index1 = 0; index1 < 1; ++index1)
                {
                    Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.196349546313286).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2());
                    int     index2  = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0.0f, 0.0f, 100, new Color(), 1f);
                    Main.dust[index2].velocity *= 0.1f;
                    Main.dust[index2].position  = projectile.Center + vector2 * (float)projectile.width / 2f;
                    Main.dust[index2].fadeIn    = 0.9f;
                }
            }
            if (Main.rand.NextBool(32))
            {
                for (int index1 = 0; index1 < 1; ++index1)
                {
                    Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.392699092626572).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2());
                    int     index2  = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0.0f, 0.0f, 155, new Color(), 0.8f);
                    Main.dust[index2].velocity *= 0.3f;
                    Main.dust[index2].position  = projectile.Center + vector2 * (float)projectile.width / 2f;
                    if (Main.rand.NextBool())
                    {
                        Main.dust[index2].fadeIn = 1.4f;
                    }
                }
            }
            if (Main.rand.NextBool())
            {
                for (int index1 = 0; index1 < 2; ++index1)
                {
                    Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.785398185253143).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2());
                    int     index2  = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0.0f, 0.0f, 0, new Color(), 1.2f);
                    Main.dust[index2].velocity *= 0.3f;
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].position  = projectile.Center + vector2 * (float)projectile.width / 2f;
                    if (Main.rand.NextBool())
                    {
                        Main.dust[index2].fadeIn = 1.4f;
                    }
                }
            }
        }
コード例 #27
0
        public override void AI()
        {
            if (projectile.localAI[1] == 0f)
            {
                projectile.localAI[1] = projectile.ai[1] + 1;

                //Main.PlaySound(SoundID.Zombie, (int)projectile.Center.X, (int)projectile.Center.Y, 20);
                Main.PlaySound(SoundID.ForceRoar, (int)projectile.Center.X, (int)projectile.Center.Y, -1, 1f, 0f);

                switch ((int)projectile.ai[1])
                {
                case 1: projectile.melee = true; break;

                case 2: projectile.ranged = true; break;

                case 3: projectile.magic = true; break;

                case 4: projectile.minion = true; break;

                case 5: projectile.thrown = true; break;

                default: break;
                }
                projectile.ai[1]     = 0f;
                projectile.netUpdate = true;
            }

            if (projectile.localAI[0]++ > 30f)
            {
                projectile.localAI[0] = 0f;
                projectile.ai[1]++;
            }

            if (projectile.ai[1] % 2 == 1) //dash
            {
                //projectile.rotation = projectile.velocity.ToRotation();
                projectile.direction = projectile.spriteDirection = projectile.velocity.X > 0 ? 1 : -1;

                /*projectile.frameCounter = 5;
                 * projectile.frame = 6;*/

                int num22 = 7;
                for (int index1 = 0; index1 < num22; ++index1)
                {
                    Vector2 vector2_1 = (Vector2.Normalize(projectile.velocity) * new Vector2((projectile.width + 50) / 2f, projectile.height) * 0.75f).RotatedBy((index1 - (num22 / 2 - 1)) * Math.PI / num22, new Vector2()) + projectile.Center;
                    Vector2 vector2_2 = ((float)(Main.rand.NextDouble() * 3.14159274101257) - 1.570796f).ToRotationVector2() * Main.rand.Next(3, 8);
                    Vector2 vector2_3 = vector2_2;
                    int     index2    = Dust.NewDust(vector2_1 + vector2_3, 0, 0, DustID.Shadowflame, vector2_2.X * 2f, vector2_2.Y * 2f, 100, new Color(), 1.4f);
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].noLight   = true;
                    Main.dust[index2].velocity /= 4f;
                    Main.dust[index2].velocity -= projectile.velocity;
                }
            }
            else //preparing to dash
            {
                int         ai0       = (int)projectile.ai[0];
                const float moveSpeed = 1f;
                if (projectile.localAI[0] == 30f)                               //just about to dash
                {
                    if (projectile.ai[0] >= 0 && Main.npc[ai0].CanBeChasedBy()) //has target
                    {
                        projectile.velocity = Main.npc[ai0].Center - projectile.Center;
                        projectile.velocity.Normalize();
                        projectile.velocity *= 27f;
                        //projectile.rotation = projectile.velocity.ToRotation();
                        projectile.direction = projectile.spriteDirection = projectile.velocity.X > 0 ? 1 : -1;

                        /*projectile.frameCounter = 5;
                         * projectile.frame = 6;*/
                    }
                    else //no target
                    {
                        projectile.localAI[0] = -1f;
                        projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 1000);
                        projectile.netUpdate  = true;

                        /*if (++projectile.frameCounter > 5)
                         * {
                         *  projectile.frameCounter = 0;
                         *  if (++projectile.frame > 5)
                         *      projectile.frame = 0;
                         * }*/
                    }
                }
                else //regular movement
                {
                    if (projectile.ai[0] >= 0 && Main.npc[ai0].CanBeChasedBy()) //has target
                    {
                        Vector2 vel = Main.npc[ai0].Center - projectile.Center;
                        //projectile.rotation = vel.ToRotation();
                        if (vel.X > 0) //projectile is on left side of target
                        {
                            vel.X -= 300;
                            projectile.direction = projectile.spriteDirection = 1;
                        }
                        else //projectile is on right side of target
                        {
                            vel.X += 300;
                            projectile.direction = projectile.spriteDirection = -1;
                        }
                        vel.Y -= 200f;
                        vel.Normalize();
                        vel *= 12f;
                        if (projectile.velocity.X < vel.X)
                        {
                            projectile.velocity.X += moveSpeed;
                            if (projectile.velocity.X < 0 && vel.X > 0)
                            {
                                projectile.velocity.X += moveSpeed;
                            }
                        }
                        else if (projectile.velocity.X > vel.X)
                        {
                            projectile.velocity.X -= moveSpeed;
                            if (projectile.velocity.X > 0 && vel.X < 0)
                            {
                                projectile.velocity.X -= moveSpeed;
                            }
                        }
                        if (projectile.velocity.Y < vel.Y)
                        {
                            projectile.velocity.Y += moveSpeed;
                            if (projectile.velocity.Y < 0 && vel.Y > 0)
                            {
                                projectile.velocity.Y += moveSpeed;
                            }
                        }
                        else if (projectile.velocity.Y > vel.Y)
                        {
                            projectile.velocity.Y -= moveSpeed;
                            if (projectile.velocity.Y > 0 && vel.Y < 0)
                            {
                                projectile.velocity.Y -= moveSpeed;
                            }
                        }
                    }
                    else //no target
                    {
                        if (projectile.velocity.X < -1f)
                        {
                            projectile.velocity.X += moveSpeed;
                        }
                        else if (projectile.velocity.X > 1f)
                        {
                            projectile.velocity.X -= moveSpeed;
                        }
                        if (projectile.velocity.Y > -8f)
                        {
                            projectile.velocity.Y -= moveSpeed;
                        }
                        else if (projectile.velocity.Y < -10f)
                        {
                            projectile.velocity.Y += moveSpeed;
                        }
                        projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 1000);
                        projectile.netUpdate = true;
                    }

                    /*if (++projectile.frameCounter > 5)
                     * {
                     *  projectile.frameCounter = 0;
                     *  if (++projectile.frame > 5)
                     *      projectile.frame = 0;
                     * }*/
                }
            }
            projectile.position += projectile.velocity / 4f;

            if (++projectile.frameCounter > 4)
            {
                projectile.frameCounter = 0;
                if (++projectile.frame >= 4)
                {
                    projectile.frame = 0;
                }
            }

            ringRotation   += rotationPerTick;
            scytheRotation += 0.5f;
        }
コード例 #28
0
        public override void AI()
        {
            if (--projectile.ai[1] < 0)
            {
                projectile.tileCollide = true;

                if (projectile.ai[0] == -1) //no target atm
                {
                    if (projectile.ai[1] % 6 == 0)
                    {
                        projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 2000, true);
                        projectile.netUpdate = true;
                        if (projectile.ai[0] == -1)
                        {
                            projectile.Kill();
                            return;
                        }
                    }
                }
                else //currently have target
                {
                    NPC npc = Main.npc[(int)projectile.ai[0]];

                    if (npc.active && npc.CanBeChasedBy()) //target is still valid
                    {
                        Vector2 distance = npc.Center - projectile.Center;
                        double  angle    = distance.ToRotation() - projectile.velocity.ToRotation();
                        if (angle > Math.PI)
                        {
                            angle -= 2.0 * Math.PI;
                        }
                        if (angle < -Math.PI)
                        {
                            angle += 2.0 * Math.PI;
                        }

                        float modifier = Math.Min(projectile.velocity.Length() / 100f, 1f);
                        projectile.velocity = projectile.velocity.RotatedBy(angle * modifier);
                    }
                    else //target lost, reset
                    {
                        projectile.ai[0]     = -1;
                        projectile.netUpdate = true;
                    }
                }
            }

            if (projectile.ai[1] < 0)
            {
                projectile.velocity = Vector2.Normalize(projectile.velocity) * MathHelper.Lerp(projectile.velocity.Length(), 24f, 0.02f);
            }

            projectile.rotation = projectile.velocity.ToRotation() + 1.570796f;

            if (projectile.localAI[0] < ProjectileID.Sets.TrailCacheLength[projectile.type])
            {
                projectile.localAI[0] += 0.1f;
            }
            else
            {
                projectile.localAI[0] = ProjectileID.Sets.TrailCacheLength[projectile.type];
            }

            projectile.localAI[1] += 0.25f;
        }
コード例 #29
0
        public override void AI()
        {
            if (Projectile.localAI[0] == 0)
            {
                Projectile.localAI[0] = 1;
                Projectile.rotation   = Main.rand.NextFloat(MathHelper.TwoPi);
                rotationDirection     = Math.Sign(Projectile.ai[1]);
                SoundEngine.PlaySound(SoundID.Item71, Projectile.Center);
            }

            if (Projectile.localAI[0] == 1) //extend out, locked to move around player
            {
                Projectile.ai[0] += Projectile.velocity.Length();
                Projectile.Center = Main.player[Projectile.owner].Center + Vector2.Normalize(Projectile.velocity) * Projectile.ai[0];

                if (Projectile.Distance(Main.player[Projectile.owner].Center) > Math.Abs(Projectile.ai[1]))
                {
                    Projectile.localAI[0]++;
                    Projectile.localAI[1] = Math.Sign(Projectile.ai[1]);
                    Projectile.ai[0]      = Math.Abs(Projectile.ai[1]) - Projectile.velocity.Length();
                    Projectile.ai[1]      = 0;
                    Projectile.netUpdate  = true;
                }
            }
            else if (Projectile.localAI[0] == 2) //orbit player, please dont ask how this code works i dont know either
            {
                //Projectile.ai[0] += Projectile.velocity.Length();
                Projectile.Center   = Main.player[Projectile.owner].Center + Vector2.Normalize(Projectile.velocity) * Projectile.ai[0];
                Projectile.Center  += Projectile.velocity.RotatedBy(Math.PI / 2 * Projectile.localAI[1]);
                Projectile.velocity = Projectile.DirectionFrom(Main.player[Projectile.owner].Center) * Projectile.velocity.Length();

                if (++Projectile.ai[1] > 180)
                {
                    Projectile.localAI[0]++;
                    Projectile.localAI[1] = 0;
                    Projectile.ai[0]      = 0;
                    Projectile.ai[1]      = 0;
                    Projectile.netUpdate  = true;
                }
            }
            else if (Projectile.timeLeft > 60) //now flying away, go into homing mode
            {
                if (Projectile.ai[0] >= 0 && Projectile.ai[0] < Main.maxNPCs)
                {
                    int ai0 = (int)Projectile.ai[0];
                    if (Main.npc[ai0].CanBeChasedBy())
                    {
                        double num4 = (Main.npc[ai0].Center - Projectile.Center).ToRotation() - Projectile.velocity.ToRotation();
                        if (num4 > Math.PI)
                        {
                            num4 -= 2.0 * Math.PI;
                        }
                        if (num4 < -1.0 * Math.PI)
                        {
                            num4 += 2.0 * Math.PI;
                        }
                        Projectile.velocity = Projectile.velocity.RotatedBy(num4 * 0.17f);
                    }
                    else
                    {
                        Projectile.ai[0]     = -1f;
                        Projectile.netUpdate = true;
                    }
                }
                else
                {
                    if (++Projectile.localAI[1] > 12f)
                    {
                        Projectile.localAI[1] = 0f;
                        Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPC(Projectile.Center, 2000);
                        Projectile.netUpdate  = true;
                    }
                }
            }

            Projectile.direction = Projectile.spriteDirection = rotationDirection;
            Projectile.rotation += Projectile.spriteDirection * 0.7f * rotationDirection;
        }
コード例 #30
0
        public override void AI()
        {
            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[1]);

            if (npc == null || !npc.CanBeChasedBy())
            {
                projectile.ai[1]     = FargoSoulsUtil.FindClosestHostileNPC(projectile.Center, 1000);
                projectile.netUpdate = true;
            }

            projectile.ai[0]++;
            if (projectile.ai[0] <= 50)
            {
                if (Main.rand.NextBool(4))
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust    dust          = Main.dust[Dust.NewDust(projectile.Center - spinningpoint * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity = true;
                    dust.position  = projectile.Center - spinningpoint * Main.rand.Next(10, 21);
                    dust.velocity  = spinningpoint.RotatedBy(1.57079637050629, new Vector2()) * 4f;
                    dust.scale     = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn    = 0.5f;
                }
                if (Main.rand.NextBool(4))
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust    dust          = Main.dust[Dust.NewDust(projectile.Center - spinningpoint * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity = true;
                    dust.position  = projectile.Center - spinningpoint * 30f;
                    dust.velocity  = spinningpoint.RotatedBy(-1.57079637050629, new Vector2()) * 2f;
                    dust.scale     = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn    = 0.5f;
                }
            }
            else if (projectile.ai[0] <= 90)
            {
                projectile.scale    = (projectile.ai[0] - 50) / 40;
                projectile.alpha    = 255 - (int)(255 * projectile.scale);
                projectile.rotation = projectile.rotation - 0.1570796f;
                if (Main.rand.NextBool())
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust    dust          = Main.dust[Dust.NewDust(projectile.Center - spinningpoint * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity  = true;
                    dust.position   = projectile.Center - spinningpoint * Main.rand.Next(10, 21);
                    dust.velocity   = spinningpoint.RotatedBy(1.57079637050629, new Vector2()) * 6f;
                    dust.scale      = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn     = 0.5f;
                    dust.customData = projectile.Center;
                }
                if (Main.rand.NextBool())
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust    dust          = Main.dust[Dust.NewDust(projectile.Center - spinningpoint * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity  = true;
                    dust.position   = projectile.Center - spinningpoint * 30f;
                    dust.velocity   = spinningpoint.RotatedBy(-1.57079637050629, new Vector2()) * 3f;
                    dust.scale      = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn     = 0.5f;
                    dust.customData = projectile.Center;
                }

                /*Vector2 rotationVector2 = Main.npc[ai1].Center - projectile.Center;
                 * rotationVector2.Normalize(); //projectile.ai[1].ToRotationVector2();
                 * Vector2 vector2_1 = rotationVector2.RotatedBy(1.57079637050629, new Vector2()) * (Main.rand.NextBool()).ToDirectionInt() * (float)Main.rand.Next(10, 21);
                 * Vector2 vector2_2 = (rotationVector2 * Main.rand.Next(-80, 81) - vector2_1) / 10f;
                 * int Type = Utils.SelectRandom<int>(Main.rand, new int[2] { 229, 229 });
                 * Dust d = Main.dust[Dust.NewDust(projectile.Center, 0, 0, Type, 0.0f, 0.0f, 0, new Color(), 1f)];
                 * d.noGravity = true;
                 * d.position = projectile.Center + vector2_1;
                 * d.velocity = vector2_2;
                 * d.scale = 0.5f + Main.rand.NextFloat();
                 * d.fadeIn = 0.5f;*/
                if (projectile.ai[0] == 90 && projectile.ai[1] != -1 && Main.netMode != NetmodeID.MultiplayerClient && npc != null)
                {
                    Vector2 rotationVector2 = npc.Center - projectile.Center;
                    rotationVector2.Normalize();

                    Vector2 vector2_3 = rotationVector2 * 8f;
                    float   ai_1      = Main.rand.Next(80);

                    int p = Player.FindClosest(projectile.Center, 0, 0);
                    if (p != -1 && Main.player[p].active && !Main.player[p].dead && !Main.player[p].ghost && projectile.Distance(Main.player[p].Center) < 1000)
                    {
                        Projectile.NewProjectile(projectile.Center.X - vector2_3.X, projectile.Center.Y - vector2_3.Y, vector2_3.X, vector2_3.Y,
                                                 mod.ProjectileType("LightningArc"), projectile.damage, projectile.knockBack, projectile.owner,
                                                 rotationVector2.ToRotation(), ai_1);
                    }
                }
            }
            else if (projectile.ai[0] <= 120)
            {
                projectile.scale    = 1f;
                projectile.alpha    = 0;
                projectile.rotation = projectile.rotation - (float)Math.PI / 60f;
                if (Main.rand.NextBool())
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust    dust          = Main.dust[Dust.NewDust(projectile.Center - spinningpoint * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity  = true;
                    dust.position   = projectile.Center - spinningpoint * Main.rand.Next(10, 21);
                    dust.velocity   = spinningpoint.RotatedBy(1.57079637050629, new Vector2()) * 6f;
                    dust.scale      = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn     = 0.5f;
                    dust.customData = projectile.Center;
                }
                else
                {
                    Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                    Dust    dust          = Main.dust[Dust.NewDust(projectile.Center - spinningpoint * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)];
                    dust.noGravity  = true;
                    dust.position   = projectile.Center - spinningpoint * 30f;
                    dust.velocity   = spinningpoint.RotatedBy(-1.57079637050629, new Vector2()) * 3f;
                    dust.scale      = 0.5f + Main.rand.NextFloat();
                    dust.fadeIn     = 0.5f;
                    dust.customData = projectile.Center;
                }
            }
            else
            {
                projectile.scale    = (float)(1.0 - (projectile.ai[0] - 120.0) / 60.0);
                projectile.alpha    = 255 - (int)(255 * projectile.scale);
                projectile.rotation = projectile.rotation - (float)Math.PI / 30f;
                if (projectile.alpha >= 255)
                {
                    projectile.Kill();
                }
                for (int index = 0; index < 2; ++index)
                {
                    switch (Main.rand.Next(3))
                    {
                    case 0:
                        Vector2 spinningpoint1 = Vector2.UnitY.RotatedByRandom(6.28318548202515) * projectile.scale;
                        Dust    dust1          = Main.dust[Dust.NewDust(projectile.Center - spinningpoint1 * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)];
                        dust1.noGravity  = true;
                        dust1.position   = projectile.Center - spinningpoint1 * Main.rand.Next(10, 21);
                        dust1.velocity   = spinningpoint1.RotatedBy(1.57079637050629, new Vector2()) * 6f;
                        dust1.scale      = 0.5f + Main.rand.NextFloat();
                        dust1.fadeIn     = 0.5f;
                        dust1.customData = projectile.Center;
                        break;

                    case 1:
                        Vector2 spinningpoint2 = Vector2.UnitY.RotatedByRandom(6.28318548202515) * projectile.scale;
                        Dust    dust2          = Main.dust[Dust.NewDust(projectile.Center - spinningpoint2 * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)];
                        dust2.noGravity  = true;
                        dust2.position   = projectile.Center - spinningpoint2 * 30f;
                        dust2.velocity   = spinningpoint2.RotatedBy(-1.57079637050629, new Vector2()) * 3f;
                        dust2.scale      = 0.5f + Main.rand.NextFloat();
                        dust2.fadeIn     = 0.5f;
                        dust2.customData = projectile.Center;
                        break;
                    }
                }
            }
        }