Beispiel #1
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (player.active && !player.dead && player.GetModPlayer <FargoPlayer>().Probes)
            {
                projectile.timeLeft = 2;
            }

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

            projectile.ai[0] -= (float)Math.PI / 60f;
            projectile.Center = player.Center + new Vector2(-60, 0).RotatedBy(projectile.ai[0]);

            if (projectile.ai[1] >= 0f && projectile.ai[1] < Main.maxNPCs)
            {
                NPC npc = Main.npc[(int)projectile.ai[1]];
                projectile.rotation = (npc.Center - projectile.Center).ToRotation();
                if (npc.CanBeChasedBy() && Collision.CanHitLine(npc.Center, 0, 0, Main.player[projectile.owner].Center, 0, 0))
                {
                    if (--projectile.localAI[0] < 0f)
                    {
                        projectile.localAI[0] = player.GetModPlayer <FargoPlayer>().MasochistSoul ? 15f : 30f;
                        if (projectile.owner == Main.myPlayer)
                        {
                            Projectile.NewProjectile(projectile.Center, new Vector2(8f, 0f).RotatedBy(projectile.rotation),
                                                     ModContent.ProjectileType <ProbeLaser>(), projectile.damage, projectile.knockBack, projectile.owner);
                        }
                        projectile.netUpdate = true;
                    }
                }
                else
                {
                    projectile.ai[1]     = -1f;
                    projectile.netUpdate = true;
                }
                projectile.rotation += (float)Math.PI;
            }
            else
            {
                if (projectile.owner == Main.myPlayer)
                {
                    projectile.rotation = (Main.MouseWorld - projectile.Center).ToRotation() + (float)Math.PI;
                }
            }

            if (++projectile.localAI[1] > 20f)
            {
                projectile.localAI[1] = 0f;
                projectile.ai[1]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1000f, true);
                projectile.netUpdate  = true;
            }
        }
        public override void AI()
        {
            if (Main.player[projectile.owner].active && !Main.player[projectile.owner].dead && Main.player[projectile.owner].GetModPlayer <FargoPlayer>().PhantasmalRing)
            {
                projectile.alpha = 0;
            }
            else
            {
                projectile.Kill();
                return;
            }

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

            if (projectile.damage == 0)
            {
                projectile.damage = (int)(1700 * Main.player[projectile.owner].minionDamage);
            }

            projectile.timeLeft = 2;
            projectile.scale    = (1f - projectile.alpha / 255f) * 0.5f;
            projectile.ai[0]   += rotationPerTick;
            if (projectile.ai[0] > PI)
            {
                projectile.ai[0]    -= 2f * PI;
                projectile.netUpdate = true;
            }

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

            if (++projectile.localAI[0] > 20)
            {
                projectile.localAI[0] = 0;
                if (projectile.owner == Main.myPlayer && Main.player[projectile.owner].GetToggleValue("MasoRing"))
                {
                    if (++projectile.localAI[1] >= 7)
                    {
                        projectile.localAI[1] = 0;
                    }
                    if (++projectile.localAI[1] >= 7)
                    {
                        projectile.localAI[1] = 0;
                    }
                    NPC npc = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1500));
                    if (npc != null)
                    {
                        Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(npc.Center), mod.ProjectileType("RingDeathray"), projectile.damage, 0f, projectile.owner, projectile.identity, projectile.localAI[1]);
                    }
                }
            }
        }
Beispiel #3
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.GoldFlame, 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, DustID.GoldFlame, projectile.velocity.X * 0.2f,
                                       projectile.velocity.Y * 0.2f, 100, default(Color), 2f);

            Main.dust[dustId3].noGravity = true;

            //direction meme
            projectile.spriteDirection = -projectile.direction;

            const int   aislotHomingCooldown            = 0;
            int         homingDelay                     = 10;
            const float desiredFlySpeedInPixelsPerFrame = 50;
            const float amountOfFramesToLerpBy          = 50; // 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.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1000f));
                if (n != null)
                {
                    Vector2 desiredVelocity = projectile.DirectionTo(n.Center) * desiredFlySpeedInPixelsPerFrame;
                    projectile.velocity = Vector2.Lerp(projectile.velocity, desiredVelocity, 1f / amountOfFramesToLerpBy);
                }
            }
        }
Beispiel #4
0
        public override void AI()
        {
            if (Main.player[Projectile.owner].active && !Main.player[Projectile.owner].dead && Main.player[Projectile.owner].GetModPlayer <FargoSoulsPlayer>().PhantasmalRing)
            {
                Projectile.alpha = 0;
            }
            else
            {
                Projectile.Kill();
                return;
            }

            Projectile.Center = Main.player[Projectile.owner].Center;

            Projectile.timeLeft = 2;
            Projectile.scale    = (1f - Projectile.alpha / 255f) * 0.5f;
            Projectile.ai[0]   += rotationPerTick;
            if (Projectile.ai[0] > PI)
            {
                Projectile.ai[0]    -= 2f * PI;
                Projectile.netUpdate = true;
            }

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

            if (++Projectile.localAI[0] > 20)
            {
                Projectile.localAI[0] = 0;
                if (Projectile.owner == Main.myPlayer && Main.player[Projectile.owner].GetToggleValue("MasoRing"))
                {
                    if (++Projectile.localAI[1] >= 7)
                    {
                        Projectile.localAI[1] = 0;
                    }
                    if (++Projectile.localAI[1] >= 7)
                    {
                        Projectile.localAI[1] = 0;
                    }
                    NPC npc = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1500, true));
                    if (npc != null)
                    {
                        FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.DirectionTo(npc.Center), ModContent.ProjectileType <RingDeathray>(), Projectile.originalDamage, 0f, Projectile.owner, Projectile.identity, Projectile.localAI[1]);
                    }
                }
            }
        }
Beispiel #5
0
        public override void AI()
        {
            if (projectile.localAI[0] == 0f)
            {
                Terraria.Audio.SoundEngine.PlaySound(SoundID.Item20, projectile.position);
                projectile.localAI[0] = 1f;
            }

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

            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;

            if (--projectile.ai[0] < 0)
            {
                projectile.netUpdate = true;
                projectile.ai[0]     = 20;
                projectile.ai[1]     = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1000, true);
            }

            if (projectile.ai[1] != -1)
            {
                int ai1 = (int)projectile.ai[1];
                if (Main.npc[ai1].CanBeChasedBy())
                {
                    double num4 = (Main.npc[ai1].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]     = -1;
                    projectile.netUpdate = true;
                }
            }
        }
        public override void AI()
        {
            int ai0 = (int)Projectile.ai[0];

            if (ai0 > -1 && ai0 < Main.maxNPCs && Main.npc[ai0].active && Main.npc[ai0].CanBeChasedBy())
            {
                if (Projectile.localAI[1] < 1f)
                {
                    float   rotation    = Projectile.velocity.ToRotation(); //homing
                    Vector2 vel         = Main.npc[ai0].Center - Projectile.Center;
                    float   targetAngle = vel.ToRotation();
                    Projectile.velocity = new Vector2(Projectile.velocity.Length(), 0f).RotatedBy(rotation.AngleLerp(targetAngle, Projectile.localAI[1]));

                    Projectile.localAI[1] += 1f / 300f;
                }
                else
                {
                    Projectile.velocity = Projectile.DirectionTo(Main.npc[ai0].Center) * Projectile.velocity.Length(); //f**k it homing
                }
            }
            else
            {
                if (++Projectile.localAI[0] > 6f)
                {
                    Projectile.localAI[0] = 1f;
                    Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1500f);
                    Projectile.netUpdate  = true;
                }
            }

            if (++Projectile.localAI[0] < 300)
            {
                Projectile.velocity *= 1.005f;
            }

            if (Projectile.localAI[0] == 0)
            {
                Projectile.localAI[0] = 1;
                Projectile.frame      = Main.rand.Next(Main.projFrames[Projectile.type]);
                Projectile.rotation   = Main.rand.NextFloat((float)Math.PI * 2);
                SoundEngine.PlaySound(SoundID.Item92, Projectile.Center);
            }

            Projectile.rotation += 0.15f * Math.Sign(Projectile.velocity.X);

            if (++Projectile.frameCounter > 2)
            {
                Projectile.frameCounter = 0;
                if (++Projectile.frame >= Main.projFrames[Projectile.type])
                {
                    Projectile.frame = 0;
                }
            }
        }
Beispiel #7
0
        public override void AI()
        {
            Player player = Main.player[Projectile.owner];

            if (player.active && !player.dead && player.GetModPlayer <FargoSoulsPlayer>().Probes)
            {
                Projectile.timeLeft = 2;
            }

            Projectile.ai[0] -= (float)Math.PI / 60f;
            Projectile.Center = player.Center + new Vector2(-60, 0).RotatedBy(Projectile.ai[0]);

            if (Projectile.ai[1] >= 0f && Projectile.ai[1] < Main.maxNPCs)
            {
                NPC npc = Main.npc[(int)Projectile.ai[1]];
                Projectile.rotation = (npc.Center - Projectile.Center).ToRotation();
                if (npc.CanBeChasedBy() && Collision.CanHitLine(npc.Center, 0, 0, Main.player[Projectile.owner].Center, 0, 0))
                {
                    if (--Projectile.localAI[0] < 0f)
                    {
                        Projectile.localAI[0] = player.GetModPlayer <FargoSoulsPlayer>().MasochistSoul ? 15f : 30f;
                        if (Projectile.owner == Main.myPlayer)
                        {
                            FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(8f, 0f).RotatedBy(Projectile.rotation),
                                                               ModContent.ProjectileType <ProbeLaser>(), Projectile.originalDamage, Projectile.knockBack, Projectile.owner);
                        }
                        Projectile.netUpdate = true;
                    }
                }
                else
                {
                    Projectile.ai[1]     = -1f;
                    Projectile.netUpdate = true;
                }
                Projectile.rotation += (float)Math.PI;
            }
            else
            {
                if (Projectile.owner == Main.myPlayer)
                {
                    Projectile.rotation = (Main.MouseWorld - Projectile.Center).ToRotation() + (float)Math.PI;
                }
            }

            if (++Projectile.localAI[1] > 20f)
            {
                Projectile.localAI[1] = 0f;
                Projectile.ai[1]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000f, true);
                Projectile.netUpdate  = true;
            }
        }
Beispiel #8
0
        public override void AI()
        {
            if (Projectile.localAI[0] == 0)
            {
                Projectile.localAI[0] = Projectile.velocity.Length() * (Main.rand.NextBool() ? 1 : -1);
                color            = new Color(50 * Main.rand.Next(6) + 5, 50 * Main.rand.Next(6) + 5, 50 * Main.rand.Next(6) + 5);
                Projectile.ai[0] = Main.rand.Next(-30, 30);
                Projectile.ai[1] = -1;
            }

            Projectile.alpha -= 25;
            if (Projectile.alpha < 0)
            {
                Projectile.alpha = 0;
            }

            if (++Projectile.ai[0] > 30)
            {
                Projectile.ai[0] = 20;

                if (Projectile.timeLeft > 45 * Projectile.MaxUpdates)
                {
                    Projectile.timeLeft = 45 * Projectile.MaxUpdates;
                }

                if (Projectile.ai[1] == -1)
                {
                    Projectile.ai[1]     = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000, true);
                    Projectile.netUpdate = true;
                }
            }

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

            if (npc != null && npc.CanBeChasedBy())
            {
                Projectile.position += npc.velocity / 5;

                Vector2 targetPos = npc.Center;
                float   offset    = 120 * Projectile.timeLeft / (30 * Projectile.MaxUpdates) * 2;
                if (Projectile.Distance(targetPos) > offset)
                {
                    targetPos += Projectile.DirectionTo(npc.Center).RotatedBy(MathHelper.PiOver2) * offset * Math.Sign(Projectile.localAI[0]);
                }
                Vector2   targetSpeed = Projectile.DirectionTo(targetPos) * Math.Abs(Projectile.localAI[0]);
                const int factor      = 8;
                Projectile.velocity = (Projectile.velocity * (factor - 1) + targetSpeed) / factor;
            }

            Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
        }
Beispiel #9
0
        public override void AI()
        {
            Projectile.spriteDirection = -Math.Sign(Projectile.velocity.X);
            Projectile.rotation        = Projectile.velocity.ToRotation();
            if (Projectile.spriteDirection > 0)
            {
                Projectile.rotation += MathHelper.Pi;
            }

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

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

            if (npc != null && npc.CanBeChasedBy())
            {
                if (Projectile.Distance(npc.Center) < Math.Max(npc.width, npc.height) / 2)
                {
                    Projectile.ai[0]     = -1;
                    Projectile.netUpdate = true;
                }
                else
                {
                    Projectile.velocity = Projectile.velocity.Length() * Projectile.DirectionTo(npc.Center);
                }

                Projectile.ai[1] = 1;
            }
            else if (Projectile.ai[1] == 0 && ++Projectile.localAI[0] == 22)
            {
                Projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1220);
                Projectile.ai[1]     = 1;
                Projectile.netUpdate = true;
            }
        }
Beispiel #10
0
 private void TargetEnemies()
 {
     projectile.ai[0] = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1000f, true, Main.player[projectile.owner].Center);
     if (projectile.ai[0] != -1)
     {
         target           = Main.npc[(int)projectile.ai[0]].Center;
         target.Y        -= Main.npc[(int)projectile.ai[0]].height + 100;
         projectile.ai[1] = projectile.localAI[1];
         if (projectile.ai[1] % 2 != 0)
         {
             projectile.ai[1]--;
         }
     }
     else
     {
         target           = Main.player[projectile.owner].Center;
         target.Y        -= Main.player[projectile.owner].height + 100;
         projectile.ai[1] = 0f;
     }
     projectile.netUpdate = true;
 }
Beispiel #11
0
        public override void AI()
        {
            if (Projectile.ai[1] > 0)        //when first spawned just move straight
            {
                Projectile.timeLeft++;       //don't expire while counting down

                if (--Projectile.ai[1] == 0) //do for one tick right before homing
                {
                    Projectile.velocity  = Vector2.Normalize(Projectile.velocity) * (Projectile.velocity.Length() + 6f);
                    Projectile.netUpdate = true;
                    for (int index1 = 0; index1 < 8; ++index1)
                    {
                        Vector2 vector2 = (Vector2.UnitX * -8f + -Vector2.UnitY.RotatedBy((double)index1 * 3.14159274101257 / 4.0, new Vector2()) * new Vector2(2f, 8f)).RotatedBy((double)Projectile.rotation - 1.57079637050629, new Vector2());
                        int     index2  = Dust.NewDust(Projectile.Center, 0, 0, 228, 0.0f, 0.0f, 0, new Color(), 1f);
                        Main.dust[index2].scale     = 1.5f;
                        Main.dust[index2].noGravity = true;
                        Main.dust[index2].position  = Projectile.Center + vector2;
                        Main.dust[index2].velocity  = Projectile.velocity * 0.0f;
                    }
                }
            }
            else //start homing
            {
                if (Projectile.ai[0] >= 0 && Projectile.ai[0] < Main.maxNPCs && Main.npc[(int)Projectile.ai[0]].CanBeChasedBy()) //have target
                {
                    double num4 = (double)(Main.npc[(int)Projectile.ai[0]].Center - Projectile.Center).ToRotation() - (double)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, new Vector2());
                }
                else //retarget
                {
                    Projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000, true);
                    Projectile.netUpdate = true;
                    if (Projectile.ai[0] == -1) //no valid targets, selfdestruct
                    {
                        Projectile.Kill();
                    }
                }

                Projectile.tileCollide = true;
                if (++Projectile.localAI[0] > 5)
                {
                    Projectile.localAI[0] = 0f;
                    for (int index1 = 0; index1 < 4; ++index1)
                    {
                        Vector2 vector2 = (Vector2.UnitX * -8f + -Vector2.UnitY.RotatedBy((double)index1 * 3.14159274101257 / 4.0, new Vector2()) * new Vector2(2f, 4f)).RotatedBy((double)Projectile.rotation - 1.57079637050629, new Vector2());
                        int     index2  = Dust.NewDust(Projectile.Center, 0, 0, 228, 0.0f, 0.0f, 0, new Color(), 1f);
                        Main.dust[index2].scale     = 1.5f;
                        Main.dust[index2].noGravity = true;
                        Main.dust[index2].position  = Projectile.Center + vector2;
                        Main.dust[index2].velocity  = Projectile.velocity * 0.0f;
                    }
                }
            }

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

            Vector2 vector21 = Vector2.UnitY.RotatedBy(Projectile.rotation, new Vector2()) * 8f * 2;
            int     index21  = Dust.NewDust(Projectile.Center, 0, 0, 228, 0.0f, 0.0f, 0, new Color(), 1f);

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

            if (++Projectile.frameCounter >= 3)
            {
                Projectile.frameCounter = 0;
                if (++Projectile.frame >= 3)
                {
                    Projectile.frame = 0;
                }
            }
        }
        public override void AI()
        {
            Player        player       = Main.player[Projectile.owner];
            PatreonPlayer patronPlayer = player.GetModPlayer <PatreonPlayer>();

            if (player.dead)
            {
                patronPlayer.PrimeMinion = false;
            }
            if (patronPlayer.PrimeMinion)
            {
                Projectile.timeLeft = 2;
            }
            // Projectile.alpha = 0;

            bool foundLimbs = false;

            int[] limbs = new int[]
            {
                ModContent.ProjectileType <PrimeMinionCannon>(),
                ModContent.ProjectileType <PrimeMinionLaserGun>(),
                ModContent.ProjectileType <PrimeMinionSaw>(),
                ModContent.ProjectileType <PrimeMinionVice>()
            };
            for (int i = 0; i < Main.projectile.Length; i++)
            {
                if (Main.projectile[i].active && Main.projectile[i].owner == Projectile.owner && limbs.Contains(Main.projectile[i].type))
                {
                    foundLimbs = true;
                    break;
                }
            }
            if (!foundLimbs && Projectile.owner == Main.myPlayer)
            {
                Projectile.Kill();
            }

            Projectile.frameCounter++;
            if (Projectile.frameCounter >= 6)
            {
                Projectile.frameCounter = 0;
                Projectile.frame        = (Projectile.frame + 1) % 6;
            }

            Vector2 targetPos;
            bool    spin = false;

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

            if (npc == null)
            {
                targetPos            = player.Top - 32 * Vector2.UnitY;
                Projectile.direction = Projectile.spriteDirection = player.direction;

                if (Projectile.Distance(targetPos) > 1200)
                {
                    Projectile.Center = player.Center;
                }

                if (++Projectile.localAI[0] > 10)
                {
                    Projectile.localAI[0] = 0;
                    Projectile.ai[1]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 800f, true, player.Center);
                    Projectile.netUpdate  = true;
                }
            }
            else
            {
                if (++Projectile.ai[0] > 360)
                {
                    spin = true;
                }

                if (Projectile.ai[0] > 540)
                {
                    Projectile.ai[0]     = 0;
                    Projectile.netUpdate = true;
                }

                targetPos = spin ? npc.Center : npc.Top - 32 * Vector2.UnitY;

                if (!spin)
                {
                    Projectile.direction = Projectile.spriteDirection = Math.Sign(npc.Center.X - Projectile.Center.X);
                }

                NPC minionAttackTargetNpc = Projectile.OwnerMinionAttackTargetNPC;
                if (minionAttackTargetNpc != null && Projectile.ai[1] != minionAttackTargetNpc.whoAmI && minionAttackTargetNpc.CanBeChasedBy())
                {
                    Projectile.ai[1]     = minionAttackTargetNpc.whoAmI;
                    Projectile.netUpdate = true;
                }

                if (!npc.CanBeChasedBy() || player.Distance(npc.Center) > 1200)
                {
                    Projectile.ai[1]     = -1;
                    Projectile.netUpdate = true;
                }
            }

            if (Projectile.Distance(targetPos) > 16 || spin)
            {
                float speed = npc == null ? 12f : 16f;
                float lerp  = 0.03f;
                lerp += 0.03f * Math.Min(1f, Projectile.localAI[1] / 300f); //gradually gets better tracking until it gets in range

                if (spin)
                {
                    speed *= 1.5f;
                    lerp  *= 2f;
                }

                Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.DirectionTo(targetPos) * speed, lerp);
            }
            else
            {
                Projectile.velocity  *= 0.99f;
                Projectile.localAI[1] = 0;
            }

            if (spin)
            {
                Projectile.rotation += MathHelper.TwoPi / 20f;
                Projectile.direction = Projectile.spriteDirection = 1;
            }
            else
            {
                Projectile.rotation = 0;
            }

            //
            //Projectile.velocity = Vector2.Lerp(Projectile.velocity, (Projectile.DirectionTo(mousePos) * 20), 0.05f);
            //Projectile.alpha = (int)(Math.Cos(Projectile.ai[0] * MathHelper.TwoPi / 180) * 122.5 + 122.5);
            // Main.NewText(Projectile.DirectionTo(Main.MouseWorld).ToString());

            /*Projectile.ai[0]++;
             * if (Projectile.ai[0] == 180)
             * {
             *
             *  Projectile.Center = Main.MouseWorld;
             *  //Projectile.velocity = Projectile.DirectionTo(Main.MouseWorld) * 8;
             *  Projectile.netUpdate = true;
             *  Projectile.ai[0] = 0;
             * }*/
        }
		public override void AI()
        {
            Player player = Main.player[projectile.owner];
			FargoPlayer modPlayer = player.GetModPlayer<FargoPlayer>();

			if (player.whoAmI == Main.myPlayer && (player.dead || !(modPlayer.ChloroEnchant || modPlayer.TerrariaSoul) || !player.GetToggleValue("Chlorophyte")))
			{
				modPlayer.ChloroEnchant = false;
                projectile.Kill();
				projectile.netUpdate = true;
                return;
            }

			projectile.netUpdate = true;

            float cooldown = 50f;
			
			float num395 = Main.mouseTextColor / 200f - 0.35f;
			num395 *= 0.2f;
			projectile.scale = num395 + 0.95f;

            if (true)
			{
                //rotation mumbo jumbo
                float distanceFromPlayer = 75;

                Lighting.AddLight(projectile.Center, 0.1f, 0.4f, 0.2f);

                projectile.position = player.Center + new Vector2(distanceFromPlayer, 0f).RotatedBy(projectile.ai[1]);
                projectile.position.X -= projectile.width / 2;
                projectile.position.Y -= projectile.height / 2;
                float rotation = 0.03f;
                projectile.ai[1] -= rotation;
                if (projectile.ai[1] > (float)Math.PI)
                {
                    projectile.ai[1] -= 2f * (float)Math.PI;
                    projectile.netUpdate = true;
                }
                projectile.rotation = projectile.ai[1] + (float)Math.PI / 2f;


                //wait for CD
                if (projectile.ai[0] != 0f)
				{
					projectile.ai[0] -= 1f;
					return;
				}

                //trying to shoot
				float num396 = projectile.position.X;
				float num397 = projectile.position.Y;
				float num398 = 700f;
				bool flag11 = false;

                NPC npc = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 700, true));
                if (npc != null)
                {
                    num396 = npc.Center.X;
                    num397 = npc.Center.Y;
                    num398 = projectile.Distance(npc.Center);
                    flag11 = true;
                }

                //shoot
				if (flag11)
				{
					Vector2 vector29 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f);
					float num404 = num396 - vector29.X;
					float num405 = num397 - vector29.Y;
					float num406 = (float)Math.Sqrt(num404 * num404 + num405 * num405);
					num406 = 10f / num406;
					num404 *= num406;
					num405 *= num406;
                    if (projectile.owner == Main.myPlayer)
					    Projectile.NewProjectile(projectile.Center.X - 4f, projectile.Center.Y, num404, num405, ProjectileID.CrystalLeafShot, projectile.damage, projectile.knockBack, projectile.owner);
					projectile.ai[0] = cooldown;
                }
			}

			if (Main.netMode == NetmodeID.Server)
				projectile.netUpdate = true;
        }
        public override void Behavior()
        {
            Player player  = Main.player[projectile.owner];
            float  spacing = projectile.width * SpacingMult;

            for (int k = 0; k < Main.maxProjectiles; k++)
            {
                Projectile otherProj = Main.projectile[k];
                if (k != projectile.whoAmI && otherProj.active && otherProj.owner == projectile.owner && otherProj.type == projectile.type &&
                    Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y) < spacing)
                {
                    if (projectile.position.X < Main.projectile[k].position.X)
                    {
                        projectile.velocity.X -= IdleAccel;
                    }
                    else
                    {
                        projectile.velocity.X += IdleAccel;
                    }
                    if (projectile.position.Y < Main.projectile[k].position.Y)
                    {
                        projectile.velocity.Y -= IdleAccel;
                    }
                    else
                    {
                        projectile.velocity.Y += IdleAccel;
                    }
                }
            }

            Vector2 targetPos  = projectile.position;
            float   targetDist = ViewDist;
            bool    target     = false;

            projectile.tileCollide = true;
            if (player.HasMinionAttackTargetNPC)
            {
                NPC npc = Main.npc[player.MinionAttackTargetNPC];
                if (Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height))
                {
                    targetDist = Vector2.Distance(projectile.Center, targetPos);
                    targetPos  = npc.Center;
                    target     = true;
                }
            }
            else
            {
                int n = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, targetDist, true);
                if (n != -1)
                {
                    targetDist = projectile.Distance(Main.npc[n].Center);
                    targetPos  = Main.npc[n].Center;
                    target     = true;
                }
            }

            if (Vector2.Distance(player.Center, projectile.Center) > (target ? 1000f : 500f))
            {
                projectile.ai[0]     = 1f;
                projectile.netUpdate = true;
            }

            if (projectile.ai[0] == 1f)
            {
                projectile.tileCollide = false;
            }
            if (target && projectile.ai[0] == 0f)
            {
                Vector2 direction = targetPos - projectile.Center;
                if (direction.Length() > ChaseDist)
                {
                    direction.Normalize();
                    projectile.velocity = (projectile.velocity * Inertia + direction * ChaseAccel) / (Inertia + 1);
                }
                else
                {
                    projectile.velocity *= (float)Math.Pow(0.97, 40.0 / Inertia);
                }
            }
            else
            {
                if (!Collision.CanHitLine(projectile.Center, 1, 1, player.Center, 1, 1))
                {
                    projectile.ai[0] = 1f;
                }
                float speed = 6f;
                if (projectile.ai[0] == 1f)
                {
                    speed = 15f;
                }
                Vector2 center    = projectile.Center;
                Vector2 direction = player.Center - center;
                projectile.ai[1]     = 3600f;
                projectile.netUpdate = true;
                int num = 1;
                for (int k = 0; k < projectile.whoAmI; k++)
                {
                    if (Main.projectile[k].active && Main.projectile[k].owner == projectile.owner && Main.projectile[k].type == projectile.type)
                    {
                        num++;
                    }
                }
                direction.X -= (10 + num * 40) * player.direction;
                direction.Y -= 70f;
                float distanceTo = direction.Length();
                if (distanceTo > 200f && speed < 9f)
                {
                    speed = 9f;
                }
                if (distanceTo < 100f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
                {
                    projectile.ai[0]     = 0f;
                    projectile.netUpdate = true;
                }

                if (distanceTo > 2000f)
                {
                    projectile.Center = player.Center;
                }
                if (distanceTo > 48f)
                {
                    direction.Normalize();
                    direction *= speed;
                    float temp = Inertia / 2f;
                    projectile.velocity = (projectile.velocity * temp + direction) / (temp + 1);
                }
                else
                {
                    projectile.direction = Main.player[projectile.owner].direction;
                    projectile.velocity *= (float)Math.Pow(0.9, 40.0 / Inertia);
                }
            }

            projectile.rotation = projectile.velocity.X * 0.05f;
            SelectFrame();
            CreateDust();
            if (projectile.velocity.X > 0f)
            {
                projectile.spriteDirection = projectile.direction = -1;
            }
            else if (projectile.velocity.X < 0f)
            {
                projectile.spriteDirection = projectile.direction = 1;
            }
            if (projectile.ai[1] > 0f)
            {
                projectile.ai[1] += 1f;
                if (Main.rand.NextBool(3))
                {
                    projectile.ai[1] += 1f;
                }
            }

            if (projectile.ai[1] > ShootCool)
            {
                projectile.ai[1]     = 0f;
                projectile.netUpdate = true;
            }

            if (projectile.ai[0] == 0f)
            {
                if (target)
                {
                    if ((targetPos - projectile.Center).X > 0f)
                    {
                        projectile.spriteDirection = projectile.direction = -1;
                    }
                    else if ((targetPos - projectile.Center).X < 0f)
                    {
                        projectile.spriteDirection = projectile.direction = 1;
                    }
                    if (projectile.ai[1] == 0f)
                    {
                        projectile.ai[1] = 1f;
                        if (Main.myPlayer == projectile.owner)
                        {
                            Vector2 shootVel = targetPos - projectile.Center;
                            if (shootVel == Vector2.Zero)
                            {
                                shootVel = new Vector2(0f, 1f);
                            }
                            shootVel.Normalize();
                            shootVel *= ShootSpeed;
                            int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, shootVel.X, shootVel.Y, Shoot, projectile.damage, projectile.knockBack,
                                                                Main.myPlayer);
                            Main.projectile[proj].timeLeft  = 300;
                            Main.projectile[proj].netUpdate = true;
                            projectile.netUpdate            = true;
                        }
                    }
                }
            }
        }
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (player.active && !player.dead && player.GetModPlayer <FargoPlayer>().SuperFlocko)
            {
                projectile.timeLeft = 2;
            }

            if (projectile.damage == 0)
            {
                projectile.damage = (int)(40f * player.minionDamage);
            }

            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.ai[0] >= 0 && projectile.ai[0] < Main.maxNPCs) //has target
            {
                NPC npc = Main.npc[(int)projectile.ai[0]];

                if (npc.CanBeChasedBy(projectile))
                {
                    Vector2 distance = npc.Center - projectile.Center;
                    float   length   = distance.Length();
                    if (length > 100f)
                    {
                        distance           /= 8f;
                        projectile.velocity = (projectile.velocity * 23f + distance) / 24f;
                    }
                    else
                    {
                        if (projectile.velocity.Length() < 12f)
                        {
                            projectile.velocity *= 1.05f;
                        }
                    }

                    projectile.localAI[0]++;
                    if (projectile.localAI[0] > 45)
                    {
                        projectile.localAI[0] = 0f;
                        if (projectile.owner == Main.myPlayer)
                        {
                            Vector2 vel = distance;
                            vel.Normalize();
                            vel *= 9f;
                            Projectile.NewProjectile(projectile.Center, vel, mod.ProjectileType("FrostWave"),
                                                     projectile.damage, projectile.knockBack, projectile.owner);
                        }
                    }

                    projectile.localAI[1]++;
                    if (projectile.localAI[1] > 6)
                    {
                        projectile.localAI[1] = 0f;
                        if (projectile.owner == Main.myPlayer)
                        {
                            Vector2 speed = new Vector2(Main.rand.Next(-1000, 1001), Main.rand.Next(-1000, 1001));
                            speed.Normalize();
                            speed *= 12f;
                            if (Main.netMode != NetmodeID.MultiplayerClient)
                            {
                                Projectile.NewProjectile(projectile.Center + speed * 4f, speed, mod.ProjectileType("FrostShard"),
                                                         projectile.damage / 2, projectile.knockBack / 2, projectile.owner);
                            }
                        }
                    }
                }
                else //forget target
                {
                    projectile.ai[0]     = -1f;
                    projectile.netUpdate = true;
                }
            }
            else //no target
            {
                Vector2 distance = player.Center - projectile.Center;
                float   length   = distance.Length();
                if (length > 1500f)
                {
                    projectile.Center   = player.Center;
                    projectile.velocity = Vector2.UnitX.RotatedByRandom(2 * Math.PI) * 12f;
                }
                else if (length > 100f)
                {
                    distance           /= 12f;
                    projectile.velocity = (projectile.velocity * 23f + distance) / 24f;
                }
                else
                {
                    if (projectile.velocity.Length() < 12f)
                    {
                        projectile.velocity *= 1.05f;
                    }
                }

                projectile.localAI[1]++;
                if (projectile.localAI[1] > 6f)
                {
                    projectile.localAI[1] = 0f;
                    projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1000f);
                    if (projectile.ai[0] != -1)
                    {
                        projectile.netUpdate = true;
                    }
                }
            }

            //projectile.rotation = projectile.velocity.ToRotation();
            projectile.rotation += projectile.velocity.Length() / 12f * (projectile.velocity.X > 0 ? -0.2f : 0.2f);
            if (++projectile.frameCounter > 3)
            {
                if (++projectile.frame >= 6)
                {
                    projectile.frame = 0;
                }
                projectile.frameCounter = 0;
            }
        }
        public override void AI()
        {
            if (Main.player[projectile.owner].active && !Main.player[projectile.owner].dead &&
                Main.player[projectile.owner].GetModPlayer <FargoPlayer>().DukeFishron)
            {
                projectile.timeLeft = 2;
            }

            if (projectile.Distance(Main.player[projectile.owner].Center) > 3000)
            {
                projectile.Center = Main.player[projectile.owner].Center;
            }

            if (projectile.localAI[0]++ > 30f) //timer handling everything else
            {
                projectile.localAI[0] = 0f;
                rotationOffset        = Main.rand.NextFloat(-PI / 2, PI / 2);
                projectile.ai[1]++;
            }

            if (projectile.localAI[1] > 0) //timer for rings on hit
            {
                projectile.localAI[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;

                if (projectile.spriteDirection < 0)
                {
                    projectile.rotation += (float)Math.PI;
                }

                /*if (projectile.localAI[0] % 2 == 0 && Main.myPlayer == projectile.owner)
                 * {
                 *  Projectile.NewProjectile(projectile.Center, 10f * Vector2.UnitX.RotatedByRandom(2 * Math.PI),
                 *      ModContent.ProjectileType<DukeBubble>(), projectile.damage, projectile.knockBack, Main.myPlayer);
                 * }*/

                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, 172, 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];
                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 + Main.npc[ai0].velocity * 10f;
                        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;

                        if (projectile.spriteDirection < 0)
                        {
                            projectile.rotation += (float)Math.PI;
                        }
                    }
                    else //no target
                    {
                        projectile.localAI[0] = -1f;
                        projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1500);
                        projectile.netUpdate  = true;
                        if (++projectile.frameCounter > 5)
                        {
                            projectile.frameCounter = 0;
                            if (++projectile.frame > 5)
                            {
                                projectile.frame = 0;
                            }
                        }
                    }
                }
                else //regular movement
                {
                    if (projectile.localAI[0] == 0)
                    {
                        projectile.localAI[0] = Main.rand.Next(10);
                    }

                    if (projectile.ai[0] >= 0 && Main.npc[ai0].CanBeChasedBy()) //has target
                    {
                        moveSpeed *= 1.5f;

                        Vector2 vel = Main.npc[ai0].Center - projectile.Center;
                        projectile.rotation = vel.ToRotation();
                        Vector2 offset = Vector2.Zero;
                        if (vel.X > 0) //projectile is on left side of target
                        {
                            offset.X             = -360;
                            projectile.direction = projectile.spriteDirection = 1;
                        }
                        else //projectile is on right side of target
                        {
                            offset.X             = 360;
                            projectile.direction = projectile.spriteDirection = -1;
                        }
                        offset = offset.RotatedBy(rotationOffset);
                        vel   += offset;
                        vel.Normalize();
                        vel *= 24f;
                        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;
                            }
                        }

                        if (projectile.spriteDirection < 0)
                        {
                            projectile.rotation += (float)Math.PI;
                        }
                    }
                    else //no target
                    {
                        Vector2 target = Main.player[projectile.owner].Center;
                        target.X -= 60 * Main.player[projectile.owner].direction * projectile.minionPos;
                        target.Y -= 40;
                        if (projectile.Distance(target) > 25)
                        {
                            moveSpeed *= 0.5f;

                            Vector2 vel = target - projectile.Center;
                            projectile.rotation  = 0;
                            projectile.direction = projectile.spriteDirection = Main.player[projectile.owner].direction;
                            vel.Normalize();
                            vel *= 24f;
                            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;
                                }
                            }
                        }

                        if (projectile.ai[0] != -1)
                        {
                            projectile.ai[0]      = -1;
                            projectile.localAI[0] = 0;
                            projectile.netUpdate  = true;
                        }

                        if (projectile.localAI[0] > 6)
                        {
                            projectile.localAI[0] = 0;
                            projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1500);
                            projectile.netUpdate  = true;
                        }
                    }
                    if (++projectile.frameCounter > 5)
                    {
                        projectile.frameCounter = 0;
                        if (++projectile.frame > 5)
                        {
                            projectile.frame = 0;
                        }
                    }
                }
            }
            projectile.position += projectile.velocity / 4f;
        }
Beispiel #17
0
        public override void AI()
        {
            Player        player       = Main.player[projectile.owner];
            PatreonPlayer patronPlayer = player.GetModPlayer <PatreonPlayer>();

            if (player.dead)
            {
                patronPlayer.PrimeMinion = false;
            }
            if (patronPlayer.PrimeMinion)
            {
                projectile.timeLeft = 2;
            }
            // projectile.alpha = 0;

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

            Vector2 targetPos;
            bool    spin = false;

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

            if (npc == null)
            {
                targetPos            = player.Top - 32 * Vector2.UnitY;
                projectile.direction = projectile.spriteDirection = player.direction;

                if (projectile.Distance(targetPos) > 1200)
                {
                    projectile.Center = player.Center;
                }

                if (++projectile.localAI[0] > 10)
                {
                    projectile.localAI[0] = 0;
                    projectile.ai[1]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 800f, true, player.Center);
                    projectile.netUpdate  = true;
                }
            }
            else
            {
                if (++projectile.ai[0] > 360)
                {
                    spin = true;
                }

                if (projectile.ai[0] > 540)
                {
                    projectile.ai[0]     = 0;
                    projectile.netUpdate = true;
                }

                targetPos = spin ? npc.Center : npc.Top - 32 * Vector2.UnitY;

                if (!spin)
                {
                    projectile.direction = projectile.spriteDirection = Math.Sign(npc.Center.X - projectile.Center.X);
                }

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

                if (!npc.CanBeChasedBy() || player.Distance(npc.Center) > 1200)
                {
                    projectile.ai[1]     = -1;
                    projectile.netUpdate = true;
                }
            }

            if (projectile.Distance(targetPos) > 16 || spin)
            {
                float speed = npc == null ? 12f : 16f;
                float lerp  = 0.03f;
                lerp += 0.03f * Math.Min(1f, projectile.localAI[1] / 300f); //gradually gets better tracking until it gets in range

                if (spin)
                {
                    speed *= 1.5f;
                    lerp  *= 2f;
                }

                projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.DirectionTo(targetPos) * speed, lerp);
            }
            else
            {
                projectile.velocity  *= 0.99f;
                projectile.localAI[1] = 0;
            }

            if (spin)
            {
                projectile.rotation += MathHelper.TwoPi / 20f;
                projectile.direction = projectile.spriteDirection = 1;
            }
            else
            {
                projectile.rotation = 0;
            }

            //
            //projectile.velocity = Vector2.Lerp(projectile.velocity, (projectile.DirectionTo(mousePos) * 20), 0.05f);
            //projectile.alpha = (int)(Math.Cos(projectile.ai[0] * MathHelper.TwoPi / 180) * 122.5 + 122.5);
            // Main.NewText(projectile.DirectionTo(Main.MouseWorld).ToString());

            /*projectile.ai[0]++;
             * if (projectile.ai[0] == 180)
             * {
             *
             *  projectile.Center = Main.MouseWorld;
             *  //projectile.velocity = projectile.DirectionTo(Main.MouseWorld) * 8;
             *  projectile.netUpdate = true;
             *  projectile.ai[0] = 0;
             * }*/
        }
Beispiel #18
0
        public override void AI()
        {
            if (!spawn)
            {
                spawn            = true;
                Projectile.ai[0] = -1;
            }

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

            if (player.active && !player.dead && player.GetModPlayer <FargoSoulsPlayer>().TwinsEX)
            {
                Projectile.timeLeft = 2;
            }

            if (Projectile.ai[0] >= 0 && Projectile.ai[0] < Main.maxNPCs) //has target
            {
                NPC minionAttackTargetNpc = Projectile.OwnerMinionAttackTargetNPC;
                if (minionAttackTargetNpc != null && Projectile.ai[0] != minionAttackTargetNpc.whoAmI && minionAttackTargetNpc.CanBeChasedBy(Projectile))
                {
                    Projectile.ai[0] = minionAttackTargetNpc.whoAmI;
                }

                NPC npc = Main.npc[(int)Projectile.ai[0]];
                if (npc.CanBeChasedBy(Projectile))
                {
                    Projectile.position += npc.velocity / 4f;

                    Vector2 target    = npc.Center + npc.velocity * Projectile.ai[1];
                    Vector2 targetPos = target + Projectile.DirectionFrom(target) * 300;
                    if (Projectile.Distance(targetPos) > 50)
                    {
                        Movement(targetPos, 0.5f);
                    }
                    Projectile.rotation = Projectile.DirectionTo(target).ToRotation() - (float)Math.PI / 2;

                    if (++Projectile.localAI[0] > 15)
                    {
                        Projectile.localAI[0] = 0;
                        if (Projectile.owner == Main.myPlayer)
                        {
                            FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center,
                                                               Projectile.DirectionTo(target) * 12, ModContent.ProjectileType <OpticLaser>(),
                                                               Projectile.originalDamage, Projectile.knockBack, Projectile.owner);
                            Projectile.ai[1]     = Main.rand.NextFloat(10, 30);
                            Projectile.netUpdate = true;
                        }
                    }
                }
                else //forget target
                {
                    Projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1500);
                    Projectile.netUpdate = true;
                }
            }
            else //no target
            {
                Projectile.ai[1] = 0;

                Vector2 targetPos = player.Center;
                targetPos.Y -= 100;

                if (Projectile.Distance(targetPos) > 3000)
                {
                    Projectile.Center = player.Center;
                }
                else if (Projectile.Distance(targetPos) > 200)
                {
                    Movement(targetPos, 0.5f);
                }

                Projectile.rotation = Projectile.velocity.ToRotation() - (float)Math.PI / 2;

                if (++Projectile.localAI[1] > 6)
                {
                    Projectile.localAI[1] = 0;
                    Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1500);
                    if (Projectile.ai[0] != -1)
                    {
                        Projectile.netUpdate = true;
                    }
                }
            }

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

            const float IdleAccel   = 0.05f;
            int         otherMinion = ModContent.ProjectileType <OpticSpazmatism>();

            foreach (Projectile p in Main.projectile.Where(p => p.active && p.owner == Projectile.owner && (p.type == Projectile.type || p.type == otherMinion) && p.whoAmI != Projectile.whoAmI && p.Distance(Projectile.Center) < Projectile.width))
            {
                Projectile.velocity.X += IdleAccel * (Projectile.Center.X < p.Center.X ? -1 : 1);
                Projectile.velocity.Y += IdleAccel * (Projectile.Center.Y < p.Center.Y ? -1 : 1);
                p.velocity.X          += IdleAccel * (p.Center.X < Projectile.Center.X ? -1 : 1);
                p.velocity.Y          += IdleAccel * (p.Center.Y < Projectile.Center.Y ? -1 : 1);
            }
        }
Beispiel #19
0
        public override void AI()
        {
            Player player = Main.player[Projectile.owner];

            if (player.whoAmI == Main.myPlayer && player.active && !player.dead && player.GetModPlayer <FargoSoulsPlayer>().TrueEyes)
            {
                Projectile.timeLeft  = 2;
                Projectile.netUpdate = true;
            }

            if (Projectile.damage == 0)
            {
                Projectile.damage = (int)(60f * player.GetDamage(DamageClass.Summon).Additive);
            }

            //lighting effect?
            DelegateMethods.v3_1 = new Vector3(0.5f, 0.9f, 1f) * 1.5f;
            Utils.PlotTileLine(Projectile.Center, Projectile.Center + Projectile.velocity * 6f, 20f, DelegateMethods.CastLightOpen);
            Utils.PlotTileLine(Projectile.Left, Projectile.Right, 20f, DelegateMethods.CastLightOpen);
            Utils.PlotTileLine(player.Center, player.Center + player.velocity * 6f, 40f, DelegateMethods.CastLightOpen);
            Utils.PlotTileLine(player.Left, player.Right, 40f, DelegateMethods.CastLightOpen);

            if (Projectile.ai[0] >= 0 && Projectile.ai[0] < Main.maxNPCs) //has target
            {
                NPC minionAttackTargetNpc = Projectile.OwnerMinionAttackTargetNPC;
                if (minionAttackTargetNpc != null && Projectile.ai[0] != minionAttackTargetNpc.whoAmI && minionAttackTargetNpc.CanBeChasedBy())
                {
                    Projectile.ai[0] = minionAttackTargetNpc.whoAmI;
                }

                Projectile.localAI[0]++;
                NPC npc = Main.npc[(int)Projectile.ai[0]];
                if (npc.CanBeChasedBy() || Projectile.ai[1] == 2f)
                {
                    switch ((int)Projectile.ai[1])
                    {
                    case 0:     //true eye movement code
                        Vector2 newVel = npc.Center - Projectile.Center + new Vector2(0f, -300f);
                        if (newVel != Vector2.Zero)
                        {
                            newVel.Normalize();
                            newVel *= 24f;
                            Projectile.velocity.X = (Projectile.velocity.X * 29 + newVel.X) / 30;
                            Projectile.velocity.Y = (Projectile.velocity.Y * 29 + newVel.Y) / 30;
                        }
                        if (Projectile.Distance(npc.Center) < 150f)
                        {
                            if (Projectile.Center.X < npc.Center.X)
                            {
                                Projectile.velocity.X -= 0.25f;
                            }
                            else
                            {
                                Projectile.velocity.X += 0.25f;
                            }

                            if (Projectile.Center.Y < npc.Center.Y)
                            {
                                Projectile.velocity.Y -= 0.25f;
                            }
                            else
                            {
                                Projectile.velocity.Y += 0.25f;
                            }
                        }

                        if (Projectile.localAI[0] > 120f)
                        {
                            if (Projectile.Distance(npc.Center) > 1500f)     //give up if too far
                            {
                                Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000);
                                Projectile.ai[1]      = 0f;
                                Projectile.localAI[1] = 0f;
                            }
                            Projectile.localAI[0] = 0f;
                            Projectile.ai[1]++;
                        }
                        break;

                    case 1:                                    //slow down
                        Projectile.velocity *= 0.95f;
                        if (Projectile.velocity.Length() < 1f) //stop
                        {
                            Projectile.velocity   = Vector2.Zero;
                            Projectile.localAI[0] = 0f;
                            Projectile.ai[1]++;
                        }
                        break;

                    case 2:     //firing laser
                        if (Projectile.localAI[0] == 1f)
                        {
                            const float PI = (float)Math.PI;
                            float       rotationDirection = PI * 2f / 3f / 90f; //positive is CW, negative is CCW
                            if (Projectile.Center.X < npc.Center.X)
                            {
                                rotationDirection *= -1;
                            }
                            localAI0 -= rotationDirection * 45f;
                            Vector2 speed = -Vector2.UnitX.RotatedBy(localAI0);
                            if (Projectile.owner == Main.myPlayer)
                            {
                                FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center - Vector2.UnitY * 6f, speed, ModContent.ProjectileType <PhantasmalDeathrayTrueEye>(),
                                                                   Projectile.originalDamage / 3 * 10, 6f, Projectile.owner, rotationDirection, Projectile.identity);
                            }
                            Projectile.localAI[1] = rotationDirection;
                        }
                        else if (Projectile.localAI[0] > 90f)
                        {
                            Projectile.localAI[0] = 0f;
                            Projectile.ai[1]++;
                        }
                        else
                        {
                            localAI0 += Projectile.localAI[1];
                        }
                        break;

                    default:
                        Projectile.ai[1] = 0f;
                        goto case 0;
                    }
                }
                else //forget target
                {
                    Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000);
                    Projectile.ai[1]      = 0f;
                    Projectile.localAI[1] = 0f;
                }

                if (Projectile.rotation > 3.14159274101257)
                {
                    Projectile.rotation = Projectile.rotation - 6.283185f;
                }
                Projectile.rotation = Projectile.rotation <= -0.005 || Projectile.rotation >= 0.005 ? Projectile.rotation * 0.96f : 0.0f;
                if (++Projectile.frameCounter >= 4)
                {
                    Projectile.frameCounter = 0;
                    if (++Projectile.frame >= Main.projFrames[Projectile.type])
                    {
                        Projectile.frame = 0;
                    }
                }
                if (Projectile.ai[1] != 2f) //custom pupil when attacking
                {
                    UpdatePupil();
                }
            }
            else
            {
                if (Projectile.localAI[1]++ > 15f)
                {
                    Projectile.localAI[0] = 0f;
                    Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000);
                    Projectile.ai[1]      = 0f;
                    Projectile.localAI[1] = 0f;
                }

                Vector2 vector2_1 = player.GetModPlayer <FargoSoulsPlayer>().PungentEyeballMinion
                    ? new Vector2(0f, 75f) : new Vector2(0f, -75f); //vanilla movement code
                Vector2 vector2_2 = player.MountedCenter + vector2_1;
                float   num1      = Vector2.Distance(Projectile.Center, vector2_2);
                if (num1 > 1500) //teleport when out of range
                {
                    Projectile.Center = player.Center + vector2_1;
                }
                Vector2 vector2_3 = vector2_2 - Projectile.Center;
                float   num2      = 4f;
                if (num1 < num2)
                {
                    Projectile.velocity *= 0.25f;
                }
                if (vector2_3 != Vector2.Zero)
                {
                    if (vector2_3.Length() < num2)
                    {
                        Projectile.velocity = vector2_3;
                    }
                    else
                    {
                        Projectile.velocity = vector2_3 * 0.1f;
                    }
                }
                if (Projectile.velocity.Length() > 6) //when moving fast, rotate in direction of velocity
                {
                    float num3 = Projectile.velocity.ToRotation() + 1.570796f;
                    if (Math.Abs(Projectile.rotation - num3) >= 3.14159274101257)
                    {
                        Projectile.rotation = num3 >= Projectile.rotation ? Projectile.rotation + 6.283185f : Projectile.rotation - 6.283185f;
                    }
                    Projectile.rotation = (Projectile.rotation * 11f + num3) / 12f;
                    if (++Projectile.frameCounter >= 4)
                    {
                        Projectile.frameCounter = 0;
                        if (++Projectile.frame >= Main.projFrames[Projectile.type])
                        {
                            Projectile.frame = 0;
                        }
                    }
                }
                else //when moving slow, calm down
                {
                    if (Projectile.rotation > 3.14159274101257)
                    {
                        Projectile.rotation = Projectile.rotation - 6.283185f;
                    }
                    Projectile.rotation = Projectile.rotation <= -0.005 || Projectile.rotation >= 0.005 ? Projectile.rotation * 0.96f : 0f;
                    if (++Projectile.frameCounter >= 6)
                    {
                        Projectile.frameCounter = 0;
                        if (++Projectile.frame >= Main.projFrames[Projectile.type])
                        {
                            Projectile.frame = 0;
                        }
                    }
                }

                UpdatePupil();
            }

            /*Main.NewText("local0 " + localAI0.ToString()
             + " local1 " + localAI1.ToString()
             + " ai0 " + Projectile.ai[0].ToString()
             + " ai1 " + Projectile.ai[1].ToString());*/
        }
Beispiel #20
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (player.active && !player.dead && player.GetModPlayer <FargoPlayer>().TwinsEX)
            {
                projectile.timeLeft = 2;
            }

            bool collide = true;

            if (projectile.ai[0] >= 0 && projectile.ai[0] < 200) //has target
            {
                NPC minionAttackTargetNpc = projectile.OwnerMinionAttackTargetNPC;
                if (minionAttackTargetNpc != null && projectile.ai[0] != minionAttackTargetNpc.whoAmI && minionAttackTargetNpc.CanBeChasedBy(projectile))
                {
                    projectile.ai[0] = minionAttackTargetNpc.whoAmI;
                }

                NPC npc = Main.npc[(int)projectile.ai[0]];
                if (npc.CanBeChasedBy(projectile))
                {
                    if (projectile.ai[1] <= 0)
                    {
                        projectile.position += npc.velocity / 2f;

                        Vector2 targetPos = npc.Center + projectile.DirectionFrom(npc.Center) * 300;
                        if (projectile.Distance(targetPos) > 50)
                        {
                            Movement(targetPos, 0.5f);
                        }
                        else if (--projectile.ai[1] < -30) //in target range for 1 second, initiate dash
                        {
                            projectile.velocity  = projectile.DirectionTo(npc.Center + npc.velocity * 10) * 30f;
                            projectile.ai[1]     = 20;
                            projectile.netUpdate = true;
                            collide = false;
                        }
                        projectile.rotation = projectile.DirectionTo(npc.Center).ToRotation() - (float)Math.PI / 2;

                        if (++projectile.localAI[0] > 7)
                        {
                            projectile.localAI[0] = 0;
                            Main.PlaySound(SoundID.Item34, projectile.Center);
                            if (projectile.owner == Main.myPlayer)
                            {
                                Projectile.NewProjectile(projectile.Center - (projectile.rotation + (float)Math.PI / 2).ToRotationVector2() * 60,
                                                         8 * projectile.DirectionTo(npc.Center).RotatedByRandom(MathHelper.ToRadians(12)), ModContent.ProjectileType <OpticFlame>(),
                                                         projectile.damage, projectile.knockBack, projectile.owner);
                            }
                        }
                    }
                    else //is dashing
                    {
                        projectile.ai[1]--;
                        projectile.rotation = projectile.velocity.ToRotation() - (float)Math.PI / 2;
                        collide             = false;
                    }
                }
                else //forget target
                {
                    projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1500);
                    projectile.ai[1]     = 0;
                    projectile.netUpdate = true;
                }
            }
            else //no target
            {
                Vector2 targetPos = player.Center;
                targetPos.Y -= 100;

                if (projectile.Distance(targetPos) > 3000)
                {
                    projectile.Center = player.Center;
                }
                else if (projectile.Distance(targetPos) > 200)
                {
                    Movement(targetPos, 0.5f);
                }

                projectile.rotation = projectile.velocity.ToRotation() - (float)Math.PI / 2;
                projectile.ai[1]    = 0;

                if (++projectile.localAI[1] > 6)
                {
                    projectile.localAI[1] = 0;
                    projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1500);
                    if (projectile.ai[0] != -1)
                    {
                        projectile.netUpdate = true;
                    }
                }
            }

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

            if (collide)
            {
                const float IdleAccel   = 0.05f;
                int         otherMinion = ModContent.ProjectileType <OpticSpazmatism>();
                foreach (Projectile p in Main.projectile.Where(p => p.active && p.owner == projectile.owner && (p.type == projectile.type || p.type == otherMinion) && p.whoAmI != projectile.whoAmI && p.Distance(projectile.Center) < projectile.width))
                {
                    projectile.velocity.X += IdleAccel * (projectile.Center.X < p.Center.X ? -1 : 1);
                    projectile.velocity.Y += IdleAccel * (projectile.Center.Y < p.Center.Y ? -1 : 1);
                    p.velocity.X          += IdleAccel * (p.Center.X < projectile.Center.X ? -1 : 1);
                    p.velocity.Y          += IdleAccel * (p.Center.Y < projectile.Center.Y ? -1 : 1);
                }
            }
        }
Beispiel #21
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (player.active && !player.dead && player.GetModPlayer <PatreonPlayer>().KingSlimeMinion)
            {
                projectile.timeLeft = 2;
            }
            else
            {
                projectile.Kill();
            }

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

            //no attacks while flying
            if (projectile.frame >= 2)
            {
                return;
            }

            //spike attack
            if (goingDown)
            {
                if (projectile.velocity.Y <= 0f) //start attack
                {
                    goingDown = false;
                    spikeAttackCounter++;

                    if (spikeAttackCounter >= 10)
                    {
                        spikeAttackCounter = 0;
                        if (projectile.owner == Main.myPlayer && FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 400, true) != -1)
                        {
                            for (int i = 0; i < 25; i++)
                            {
                                Projectile.NewProjectile(new Vector2(projectile.Center.X + Main.rand.Next(-5, 5), projectile.Center.Y - 15),
                                                         new Vector2(Main.rand.NextFloat(-6, 6), Main.rand.NextFloat(-8, -5)),
                                                         ModContent.ProjectileType <KingSlimeSpike>(), projectile.damage, 0f, Main.myPlayer);
                            }
                        }
                    }
                }
            }
            else if (projectile.velocity.Y > 0)
            {
                goingDown = true;
            }

            //slime rain attack
            if (++slimeAttackCounter > 150)
            {
                slimeAttackCounter = 0;

                int target = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 800, true);
                if (target != -1 && projectile.owner == Main.myPlayer)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        Vector2 spawn = Main.npc[target].Center + Main.npc[target].velocity * Main.rand.NextFloat(15f);
                        spawn.X += Main.rand.Next(-50, 51);
                        spawn.Y -= Main.rand.Next(600, 701);
                        Vector2 speed = Main.npc[target].Center - spawn;
                        speed.Normalize();
                        speed *= Main.rand.NextFloat(10f, 20f);
                        Projectile.NewProjectile(spawn, speed, ModContent.ProjectileType <KingSlimeBallPiercing>(), projectile.damage, 0f, Main.myPlayer);
                    }
                }
            }
        }
Beispiel #22
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (player.whoAmI == Main.myPlayer && player.active && !player.dead && player.GetModPlayer <FargoPlayer>().TrueEyes)
            {
                projectile.timeLeft  = 2;
                projectile.netUpdate = true;
            }

            if (projectile.damage == 0)
            {
                projectile.damage = (int)(60f * player.minionDamage);
            }

            //lighting effect?
            DelegateMethods.v3_1 = new Vector3(0.5f, 0.9f, 1f) * 1.5f;
            Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * 6f, 20f, new Utils.PerLinePoint(DelegateMethods.CastLightOpen));
            Utils.PlotTileLine(projectile.Left, projectile.Right, 20f, new Utils.PerLinePoint(DelegateMethods.CastLightOpen));
            Utils.PlotTileLine(player.Center, player.Center + player.velocity * 6f, 40f, new Utils.PerLinePoint(DelegateMethods.CastLightOpen));
            Utils.PlotTileLine(player.Left, player.Right, 40f, new Utils.PerLinePoint(DelegateMethods.CastLightOpen));

            if (projectile.ai[0] >= 0 && projectile.ai[0] < Main.maxNPCs) //has target
            {
                NPC minionAttackTargetNpc = projectile.OwnerMinionAttackTargetNPC;
                if (minionAttackTargetNpc != null && projectile.ai[0] != minionAttackTargetNpc.whoAmI && minionAttackTargetNpc.CanBeChasedBy(projectile))
                {
                    projectile.ai[0] = minionAttackTargetNpc.whoAmI;
                }

                projectile.localAI[0]++;
                NPC npc = Main.npc[(int)projectile.ai[0]];
                if (npc.CanBeChasedBy(projectile))
                {
                    switch ((int)projectile.ai[1])
                    {
                    case 0:     //true eye movement code
                        Vector2 newVel = npc.Center - projectile.Center + new Vector2(200f, -200f);
                        if (newVel != Vector2.Zero)
                        {
                            newVel.Normalize();
                            newVel *= 24f;
                            projectile.velocity.X = (projectile.velocity.X * 29 + newVel.X) / 30;
                            projectile.velocity.Y = (projectile.velocity.Y * 29 + newVel.Y) / 30;
                        }
                        if (projectile.Distance(npc.Center) < 150f)
                        {
                            if (projectile.Center.X < npc.Center.X)
                            {
                                projectile.velocity.X -= 0.25f;
                            }
                            else
                            {
                                projectile.velocity.X += 0.25f;
                            }

                            if (projectile.Center.Y < npc.Center.Y)
                            {
                                projectile.velocity.Y -= 0.25f;
                            }
                            else
                            {
                                projectile.velocity.Y += 0.25f;
                            }
                        }

                        if (projectile.localAI[0] > 90f)
                        {
                            if (projectile.Distance(npc.Center) > 1500f)     //give up if too far
                            {
                                projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1000);
                                projectile.ai[1]     = 0f;
                                projectile.netUpdate = true;
                            }
                            projectile.localAI[0] = 0f;
                            projectile.ai[1]++;
                        }

                        if (projectile.rotation > 3.14159274101257)
                        {
                            projectile.rotation = projectile.rotation - 6.283185f;
                        }
                        projectile.rotation = projectile.rotation <= -0.005 || projectile.rotation >= 0.005 ? projectile.rotation * 0.96f : 0.0f;
                        break;

                    case 1:                              //slow down
                        if (projectile.localAI[0] == 1f) //spawn orb ring
                        {
                            const int   max      = 6;
                            const float distance = 50f;
                            const float rotation = 2f * (float)Math.PI / max;
                            for (int i = 0; i < max; i++)
                            {
                                Vector2 spawnPos = projectile.Center - Vector2.UnitY * 6f + new Vector2(distance, 0f).RotatedBy(rotation * i);
                                if (projectile.owner == Main.myPlayer)
                                {
                                    Projectile.NewProjectile(spawnPos, Vector2.Zero, mod.ProjectileType("PhantasmalSphereTrueEye"),
                                                             projectile.damage / 3 * 11, 10f, projectile.owner, projectile.whoAmI, i);
                                }
                            }
                        }
                        projectile.velocity *= 0.95f;
                        if (projectile.localAI[0] > 60f)
                        {
                            projectile.velocity   = Vector2.Zero;
                            projectile.localAI[0] = 0f;
                            projectile.ai[1]++;
                        }

                        if (projectile.rotation > 3.14159274101257)
                        {
                            projectile.rotation = projectile.rotation - 6.283185f;
                        }
                        projectile.rotation = projectile.rotation <= -0.005 || projectile.rotation >= 0.005 ? projectile.rotation * 0.96f : 0.0f;
                        break;

                    case 2:     //ramming
                        if (projectile.localAI[0] == 1f)
                        {
                            Main.PlaySound(SoundID.Zombie, (int)projectile.Center.X, (int)projectile.Center.Y, 102, 0.75f, 0.0f);
                            projectile.velocity = npc.Center - projectile.Center;
                            if (projectile.velocity != Vector2.Zero)
                            {
                                projectile.velocity.Normalize();
                                projectile.velocity *= 24f;
                            }
                        }
                        else if (projectile.localAI[0] > 10f)
                        {
                            projectile.localAI[0] = 0f;
                            projectile.ai[1]++;
                        }

                        float num3 = projectile.velocity.ToRotation() + 1.570796f;
                        if (Math.Abs(projectile.rotation - num3) >= 3.14159274101257)
                        {
                            projectile.rotation = num3 >= projectile.rotation ? projectile.rotation + 6.283185f : projectile.rotation - 6.283185f;
                        }
                        float num4 = 12f;
                        projectile.rotation = (projectile.rotation * (num4 - 1f) + num3) / num4;
                        break;

                    default:
                        projectile.ai[1] = 0f;
                        goto case 0;
                    }
                }
                else //forget target
                {
                    if (projectile.ai[1] == 0)
                    {
                        projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1000);
                        projectile.ai[1]      = 0f;
                        projectile.localAI[0] = 0f;
                        projectile.localAI[1] = 0f;
                    }
                    else //try to recover while making balls
                    {
                        float maxDistance    = 1000f;
                        int   possibleTarget = -1;
                        for (int i = 0; i < 200; i++)
                        {
                            NPC target = Main.npc[i];
                            if (target.CanBeChasedBy(projectile))// && Collision.CanHitLine(projectile.Center, 0, 0, target.Center, 0, 0))
                            {
                                float npcDistance = projectile.Distance(target.Center);
                                if (npcDistance < maxDistance)
                                {
                                    maxDistance    = npcDistance;
                                    possibleTarget = i;
                                }
                            }
                        }
                        projectile.ai[0] = possibleTarget;
                        if (projectile.ai[0] == -1f) //no nearby targets, accept defeat
                        {
                            projectile.localAI[0] = 0f;
                            projectile.localAI[1] = 0f;
                            projectile.ai[1]      = 0f;
                            projectile.netUpdate  = true;
                        }
                    }
                }

                //rotation is handled in switch
                if (++projectile.frameCounter >= 4)
                {
                    projectile.frameCounter = 0;
                    if (++projectile.frame >= Main.projFrames[projectile.type])
                    {
                        projectile.frame = 0;
                    }
                }
                UpdatePupil();
            }
            else
            {
                if (projectile.localAI[1]++ > 15f)
                {
                    projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1000);
                    projectile.ai[1]      = 0f;
                    projectile.localAI[0] = 0f;
                    projectile.localAI[1] = 0f;
                    projectile.netUpdate  = true;
                }

                Vector2 vector2_1 = new Vector2(player.direction * 100, 0f); //vanilla movement code
                Vector2 vector2_2 = player.MountedCenter + vector2_1;
                float   num1      = Vector2.Distance(projectile.Center, vector2_2);
                if (num1 > 1500) //teleport when out of range
                {
                    projectile.Center = player.Center + vector2_1;
                }
                Vector2 vector2_3 = vector2_2 - projectile.Center;
                float   num2      = 4f;
                if (num1 < num2)
                {
                    projectile.velocity *= 0.25f;
                }
                if (vector2_3 != Vector2.Zero)
                {
                    if (vector2_3.Length() < num2)
                    {
                        projectile.velocity = vector2_3;
                    }
                    else
                    {
                        projectile.velocity = vector2_3 * 0.1f;
                    }
                }
                if (projectile.velocity.Length() > 6) //when moving fast, rotate in direction of velocity
                {
                    float num3 = projectile.velocity.ToRotation() + 1.570796f;
                    if (Math.Abs(projectile.rotation - num3) >= 3.14159274101257)
                    {
                        projectile.rotation = num3 >= projectile.rotation ? projectile.rotation + 6.283185f : projectile.rotation - 6.283185f;
                    }
                    projectile.rotation = (projectile.rotation * 11f + num3) / 12f;
                    if (++projectile.frameCounter >= 4)
                    {
                        projectile.frameCounter = 0;
                        if (++projectile.frame >= Main.projFrames[projectile.type])
                        {
                            projectile.frame = 0;
                        }
                    }
                }
                else //when moving slow, calm down
                {
                    if (projectile.rotation > 3.14159274101257)
                    {
                        projectile.rotation = projectile.rotation - 6.283185f;
                    }
                    projectile.rotation = projectile.rotation <= -0.005 || projectile.rotation >= 0.005 ? projectile.rotation * 0.96f : 0f;
                    if (++projectile.frameCounter >= 6)
                    {
                        projectile.frameCounter = 0;
                        if (++projectile.frame >= Main.projFrames[projectile.type])
                        {
                            projectile.frame = 0;
                        }
                    }
                }

                UpdatePupil();
            }

            /*Main.NewText("local0 " + localAI0.ToString()
             + " local1 " + localAI1.ToString()
             + " ai0 " + projectile.ai[0].ToString()
             + " ai1 " + projectile.ai[1].ToString());*/
        }
Beispiel #23
0
        public override void AI()
        {
            Projectile.scale = 1;

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

            int target = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 2000);

            if (++Projectile.ai[0] == 50) //spawn axe
            {
                Projectile.netUpdate = true;
                if (Projectile.owner == Main.myPlayer)
                {
                    Vector2 offset = new Vector2(0, -275).RotatedBy(Math.PI / 4 * Projectile.spriteDirection);
                    FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center + offset, Vector2.Zero, ModContent.ProjectileType <SparklingLoveBig>(),
                                                       Projectile.originalDamage, Projectile.knockBack, Projectile.owner, 0f, Projectile.identity);
                }
            }
            else if (Projectile.ai[0] < 100)
            {
                Vector2 targetPos;

                if (target != -1 && Main.npc[target].CanBeChasedBy(Projectile))
                {
                    targetPos            = Main.npc[target].Center;
                    Projectile.direction = Projectile.spriteDirection = Projectile.Center.X > targetPos.X ? 1 : -1;
                    targetPos.X         += 500 * Projectile.direction;
                    targetPos.Y         -= 200;
                }
                else
                {
                    Projectile.direction = Projectile.spriteDirection = -Main.player[Projectile.owner].direction;
                    targetPos            = Main.player[Projectile.owner].Center + new Vector2(100 * Projectile.direction, -100);
                }

                if (Projectile.Distance(targetPos) > 50)
                {
                    Movement(targetPos, 1f);
                }
            }
            else if (Projectile.ai[0] == 99 || Projectile.ai[0] == 100)
            {
                Projectile.netUpdate = true;

                if (Projectile.owner == Main.myPlayer)
                {
                    Vector2 targetPos;

                    if (target != -1 && Main.npc[target].CanBeChasedBy(Projectile))
                    {
                        targetPos = Main.npc[target].Center + Main.npc[target].velocity * 10;
                    }
                    else
                    {
                        targetPos = Main.MouseWorld;
                    }

                    Projectile.direction = Projectile.spriteDirection = Projectile.Center.X > targetPos.X ? 1 : -1;

                    targetPos.X += 360 * Projectile.direction;

                    if (Projectile.ai[0] == 100)
                    {
                        Projectile.velocity = (targetPos - Projectile.Center) / Projectile.timeLeft;

                        Projectile.position += Projectile.velocity; //makes sure the offset is right
                    }
                }
            }

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

            int num812 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height,
                                      86, Projectile.velocity.X / 2, Projectile.velocity.Y / 2, 0, default(Color), 1.5f);

            Main.dust[num812].noGravity = true;
        }
        public override void AI()
        {
            Player      player    = Main.player[projectile.owner];
            FargoPlayer modPlayer = player.GetModPlayer <FargoPlayer>();

            if (player.dead)
            {
                modPlayer.BigBrainMinion = false;
            }
            if (modPlayer.BigBrainMinion)
            {
                projectile.timeLeft = 2;
            }

            projectile.frameCounter++;
            if (projectile.frameCounter >= 8)
            {
                projectile.frameCounter = 0;
                projectile.frame        = (projectile.frame + 1) % 12;
            }

            float slotsModifier = Math.Min(projectile.minionSlots / MaxMinionSlots, 1f);

            projectile.ai[0] += 0.1f + 0.3f * slotsModifier;
            projectile.alpha  = (int)(Math.Cos(projectile.ai[0] / 0.4f * MathHelper.TwoPi / 180) * 60) + 60;

            float oldScale = projectile.scale;

            projectile.scale = 0.75f + 0.5f * slotsModifier;

            projectile.position = projectile.Center;
            projectile.width    = (int)(projectile.width * projectile.scale / oldScale);
            projectile.height   = (int)(projectile.height * projectile.scale / oldScale);
            projectile.Center   = projectile.position;

            NPC  targetnpc  = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1000, center: Main.player[projectile.owner].MountedCenter));
            bool targetting = targetnpc != null; //targetting code, prioritize targetted npcs, then look for closest if none is found

            if (targetting)
            {
                if (++projectile.localAI[0] > 5)
                {
                    projectile.localAI[0] = 0;

                    if (projectile.owner == Main.myPlayer)
                    {
                        const float speed  = 18f;
                        int         damage = (int)(projectile.damage * projectile.scale); //damage directly proportional to projectile scale, change later???
                        int         type   = ModContent.ProjectileType <BigBrainIllusion>();

                        //Vector2 spawnpos = targetnpc.Center + Main.rand.NextVector2CircularEdge(150, 150);
                        //Projectile.NewProjectile(spawnpos, speed * Vector2.Normalize(targetnpc.Center - spawnpos), type, damage, projectile.knockBack, projectile.owner, projectile.scale);

                        Vector2 spawnFromMe = Main.player[projectile.owner].Center + (projectile.Center - Main.player[projectile.owner].Center).RotatedBy(MathHelper.TwoPi / 4 * Main.rand.Next(4));
                        Vector2 vel         = speed * Vector2.Normalize(targetnpc.Center + targetnpc.velocity * 15 - spawnFromMe);
                        Projectile.NewProjectile(spawnFromMe, vel, type, damage, projectile.knockBack, projectile.owner, projectile.scale);
                    }
                }
            }

            projectile.Center = player.Center + new Vector2(0, (200 + projectile.alpha) * projectile.scale).RotatedBy(projectile.ai[1] + projectile.ai[0] / MathHelper.TwoPi);
        }
Beispiel #25
0
        public override void AI()
        {
            Player player = Main.player[Projectile.owner];

            if (player.active && !player.dead && player.GetModPlayer <FargoSoulsPlayer>().MagicalBulb)
            {
                Projectile.timeLeft = 2;
            }

            NPC minionAttackTargetNpc = Projectile.OwnerMinionAttackTargetNPC;

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

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

                if (npc.CanBeChasedBy())
                {
                    Vector2 target = npc.Center - Projectile.Center;
                    float   length = target.Length();
                    if (length > 1000f) //too far, lose target
                    {
                        Projectile.ai[0]     = -1f;
                        Projectile.netUpdate = true;
                    }
                    else if (length > 50f)
                    {
                        target.Normalize();
                        target *= 16f;
                        Projectile.velocity = (Projectile.velocity * 40f + target) / 41f;
                    }

                    Projectile.localAI[0]++;
                    if (Projectile.localAI[0] > 15f) //shoot seed/spiky ball
                    {
                        Projectile.localAI[0] = 0f;
                        if (Projectile.owner == Main.myPlayer)
                        {
                            Vector2 speed = Projectile.velocity;
                            speed.Normalize();
                            speed *= 17f;
                            float damage = Projectile.originalDamage * 2f / 3f;
                            int   type;
                            if (Main.rand.NextBool())
                            {
                                damage = damage * 5f / 4f;
                                type   = ModContent.ProjectileType <PoisonSeedPlanterasChild>();
                                SoundEngine.PlaySound(SoundID.Item17, Projectile.position);
                            }
                            else if (Main.rand.NextBool(6))
                            {
                                damage = damage * 3f / 2f;
                                type   = ModContent.ProjectileType <SpikyBallPlanterasChild>();
                            }
                            else
                            {
                                type = ModContent.ProjectileType <SeedPlanterasChild>();
                                SoundEngine.PlaySound(SoundID.Item17, Projectile.position);
                            }

                            if (Projectile.owner == Main.myPlayer)
                            {
                                FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(),
                                                                   Projectile.Center, speed, type, (int)damage, Projectile.knockBack, Projectile.owner);
                            }
                        }
                    }
                }
                else //forget target
                {
                    Projectile.ai[0]     = -1f;
                    Projectile.netUpdate = true;
                }
            }
            else //no target
            {
                Vector2 target = player.Center - Projectile.Center;
                target.Y -= 50f;
                float length = target.Length();
                if (length > 2000f)
                {
                    Projectile.Center    = player.Center;
                    Projectile.ai[0]     = -1f;
                    Projectile.netUpdate = true;
                }
                else if (length > 70f)
                {
                    target.Normalize();
                    target *= (length > 200f) ? 10f : 6f;
                    Projectile.velocity = (Projectile.velocity * 40f + target) / 41f;
                }

                Projectile.localAI[1]++;
                if (Projectile.localAI[1] > 6f)
                {
                    Projectile.localAI[1] = 0f;
                    Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000, true, player.Center);
                    Projectile.netUpdate  = true;
                }
            }

            Projectile.rotation = Projectile.velocity.ToRotation();
        }
        public override void AI()
        {
            Player player = Main.player[Projectile.owner];

            if (player.whoAmI == Main.myPlayer && player.active && !player.dead && player.GetModPlayer <FargoSoulsPlayer>().TrueEyes)
            {
                Projectile.timeLeft  = 2;
                Projectile.netUpdate = true;
            }

            if (Projectile.damage == 0)
            {
                Projectile.damage = (int)(60f * player.GetDamage(DamageClass.Summon).Additive);
            }

            //lighting effect?
            DelegateMethods.v3_1 = new Vector3(0.5f, 0.9f, 1f) * 1.5f;
            Utils.PlotTileLine(Projectile.Center, Projectile.Center + Projectile.velocity * 6f, 20f, DelegateMethods.CastLightOpen);
            Utils.PlotTileLine(Projectile.Left, Projectile.Right, 20f, DelegateMethods.CastLightOpen);
            Utils.PlotTileLine(player.Center, player.Center + player.velocity * 6f, 40f, DelegateMethods.CastLightOpen);
            Utils.PlotTileLine(player.Left, player.Right, 40f, DelegateMethods.CastLightOpen);

            if (Projectile.ai[0] >= 0 && Projectile.ai[0] < Main.maxNPCs) //has target
            {
                NPC minionAttackTargetNpc = Projectile.OwnerMinionAttackTargetNPC;
                if (minionAttackTargetNpc != null && Projectile.ai[0] != minionAttackTargetNpc.whoAmI && minionAttackTargetNpc.CanBeChasedBy())
                {
                    Projectile.ai[0] = minionAttackTargetNpc.whoAmI;
                }

                Projectile.localAI[0]++;
                NPC npc = Main.npc[(int)Projectile.ai[0]];
                if (npc.CanBeChasedBy())
                {
                    switch ((int)Projectile.ai[1])
                    {
                    case 0:     //true eye movement code
                        Vector2 newVel = npc.Center - Projectile.Center + new Vector2(200f, -200f);
                        if (newVel != Vector2.Zero)
                        {
                            newVel.Normalize();
                            newVel *= 24f;
                            Projectile.velocity.X = (Projectile.velocity.X * 29 + newVel.X) / 30;
                            Projectile.velocity.Y = (Projectile.velocity.Y * 29 + newVel.Y) / 30;
                        }
                        if (Projectile.Distance(npc.Center) < 150f)
                        {
                            if (Projectile.Center.X < npc.Center.X)
                            {
                                Projectile.velocity.X -= 0.25f;
                            }
                            else
                            {
                                Projectile.velocity.X += 0.25f;
                            }

                            if (Projectile.Center.Y < npc.Center.Y)
                            {
                                Projectile.velocity.Y -= 0.25f;
                            }
                            else
                            {
                                Projectile.velocity.Y += 0.25f;
                            }
                        }

                        if (Projectile.localAI[0] > 90f)
                        {
                            if (Projectile.Distance(npc.Center) > 1500f)     //give up if too far
                            {
                                Projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000);
                                Projectile.ai[1]     = 0f;
                                Projectile.netUpdate = true;
                            }
                            Projectile.localAI[0] = 0f;
                            Projectile.ai[1]++;
                        }

                        if (Projectile.rotation > 3.14159274101257)
                        {
                            Projectile.rotation = Projectile.rotation - 6.283185f;
                        }
                        Projectile.rotation = Projectile.rotation <= -0.005 || Projectile.rotation >= 0.005 ? Projectile.rotation * 0.96f : 0.0f;
                        break;

                    case 1:                              //slow down
                        if (Projectile.localAI[0] == 1f) //spawn orb ring
                        {
                            const int   max      = 6;
                            const float distance = 50f;
                            const float rotation = 2f * (float)Math.PI / max;
                            for (int i = 0; i < max; i++)
                            {
                                Vector2 spawnPos = Projectile.Center - Vector2.UnitY * 6f + new Vector2(distance, 0f).RotatedBy(rotation * i);
                                if (Projectile.owner == Main.myPlayer)
                                {
                                    FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), spawnPos, Vector2.Zero, ModContent.ProjectileType <PhantasmalSphereTrueEye>(),
                                                                       Projectile.originalDamage / 3 * 11, 10f, Projectile.owner, Projectile.whoAmI, i);
                                }
                            }
                        }
                        Projectile.velocity *= 0.95f;
                        if (Projectile.localAI[0] > 60f)
                        {
                            Projectile.velocity   = Vector2.Zero;
                            Projectile.localAI[0] = 0f;
                            Projectile.ai[1]++;
                        }

                        if (Projectile.rotation > 3.14159274101257)
                        {
                            Projectile.rotation = Projectile.rotation - 6.283185f;
                        }
                        Projectile.rotation = Projectile.rotation <= -0.005 || Projectile.rotation >= 0.005 ? Projectile.rotation * 0.96f : 0.0f;
                        break;

                    case 2:     //ramming
                        if (Projectile.localAI[0] == 1f)
                        {
                            SoundEngine.PlaySound(new SoundStyle("Terraria/Sounds/Zombie_102") with {
                                Volume = 0.75f, Pitch = 0
                            }, Projectile.Center);
                            Projectile.velocity = npc.Center - Projectile.Center;
                            if (Projectile.velocity != Vector2.Zero)
                            {
                                Projectile.velocity.Normalize();
                                Projectile.velocity *= 24f;
                            }
                        }
                        else if (Projectile.localAI[0] > 10f)
                        {
                            Projectile.localAI[0] = 0f;
                            Projectile.ai[1]++;
                        }

                        float num3 = Projectile.velocity.ToRotation() + 1.570796f;
                        if (Math.Abs(Projectile.rotation - num3) >= 3.14159274101257)
                        {
                            Projectile.rotation = num3 >= Projectile.rotation ? Projectile.rotation + 6.283185f : Projectile.rotation - 6.283185f;
                        }
                        float num4 = 12f;
                        Projectile.rotation = (Projectile.rotation * (num4 - 1f) + num3) / num4;
                        break;
Beispiel #27
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (player.active && !player.dead && player.GetModPlayer <FargoPlayer>().MagicalBulb)
            {
                projectile.timeLeft = 2;
            }

            if (projectile.damage == 0)
            {
                projectile.damage = (int)(60f * player.minionDamage);
            }

            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.ai[0] >= 0 && projectile.ai[0] < Main.maxNPCs) //has target
            {
                NPC npc = Main.npc[(int)projectile.ai[0]];

                if (npc.CanBeChasedBy(projectile))
                {
                    Vector2 target = npc.Center - projectile.Center;
                    float   length = target.Length();
                    if (length > 1000f) //too far, lose target
                    {
                        projectile.ai[0]     = -1f;
                        projectile.netUpdate = true;
                    }
                    else if (length > 50f)
                    {
                        target.Normalize();
                        target *= 16f;
                        projectile.velocity = (projectile.velocity * 40f + target) / 41f;
                    }

                    projectile.localAI[0]++;
                    if (projectile.localAI[0] > 15f) //shoot seed/spiky ball
                    {
                        projectile.localAI[0] = 0f;
                        if (projectile.owner == Main.myPlayer)
                        {
                            Vector2 speed = projectile.velocity;
                            speed.Normalize();
                            speed *= 17f;
                            int damage = projectile.damage * 2 / 3;
                            int type;
                            if (Main.rand.NextBool())
                            {
                                damage = damage * 5 / 4;
                                type   = mod.ProjectileType("PoisonSeedPlanterasChild");
                                Main.PlaySound(SoundID.Item17, projectile.position);
                            }
                            else if (Main.rand.NextBool(6))
                            {
                                damage = damage * 3 / 2;
                                type   = mod.ProjectileType("SpikyBallPlanterasChild");
                            }
                            else
                            {
                                type = mod.ProjectileType("SeedPlanterasChild");
                                Main.PlaySound(SoundID.Item17, projectile.position);
                            }
                            if (projectile.owner == Main.myPlayer)
                            {
                                Projectile.NewProjectile(projectile.Center, speed, type, damage, projectile.knockBack, projectile.owner);
                            }
                        }
                    }
                }
                else //forget target
                {
                    projectile.ai[0]     = -1f;
                    projectile.netUpdate = true;
                }
            }
            else //no target
            {
                Vector2 target = player.Center - projectile.Center;
                target.Y -= 50f;
                float length = target.Length();
                if (length > 2000f)
                {
                    projectile.Center    = player.Center;
                    projectile.ai[0]     = -1f;
                    projectile.netUpdate = true;
                }
                else if (length > 70f)
                {
                    target.Normalize();
                    target *= (length > 200f) ? 10f : 6f;
                    projectile.velocity = (projectile.velocity * 40f + target) / 41f;
                }

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

            projectile.rotation = projectile.velocity.ToRotation();
        }
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (player.active && !player.dead && player.GetModPlayer <FargoPlayer>().SkeletronArms)
            {
                projectile.timeLeft = 2;
            }

            if (projectile.damage == 0)
            {
                projectile.damage = 18;
                if (player.GetModPlayer <FargoPlayer>().SupremeDeathbringerFairy)
                {
                    projectile.damage = 24;
                }
                if (player.GetModPlayer <FargoPlayer>().MasochistSoul)
                {
                    projectile.damage = 48;
                }
                projectile.damage = (int)(projectile.damage * player.minionDamage);
            }

            //tentacle head movement (homing)
            Vector2 playerVel = player.position - player.oldPosition;

            projectile.position += playerVel;
            projectile.ai[0]++;
            if (projectile.ai[0] >= 0f)
            {
                Vector2 home = player.Center;
                home.X += 200f;
                home.Y -= 50f;
                Vector2 distance = home - projectile.Center;
                float   range    = distance.Length();
                distance.Normalize();
                if (projectile.ai[0] == 0f)
                {
                    if (range > 15f)
                    {
                        projectile.ai[0] = -1f; //if in fast mode, stay fast until back in range
                        if (range > 1300f)
                        {
                            projectile.Kill();
                            return;
                        }
                    }
                    else
                    {
                        projectile.velocity.Normalize();
                        projectile.velocity *= 3f + Main.rand.NextFloat(3f);
                        projectile.netUpdate = true;
                    }
                }
                else
                {
                    distance /= 8f;
                }
                if (range > 120f) //switch to fast return mode
                {
                    projectile.ai[0]     = -1f;
                    projectile.netUpdate = true;
                }
                projectile.velocity += distance;
                if (range > 30f)
                {
                    projectile.velocity *= 0.96f;
                }

                if (projectile.ai[0] > 90f) //attack nearby enemy
                {
                    projectile.ai[0] = 20f;
                    NPC npc = FargoSoulsUtil.NPCExists(FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 400));
                    if (npc != null)
                    {
                        projectile.velocity = npc.Center - projectile.Center;
                        projectile.velocity.Normalize();
                        projectile.velocity *= 16f;
                        projectile.velocity += npc.velocity / 2f;
                        projectile.velocity -= playerVel / 2f;
                        projectile.ai[0]    *= -1f;
                    }
                    projectile.netUpdate = true;
                }
            }

            Vector2 angle = player.Center - projectile.Center;

            angle.X            += 200f;
            angle.Y            += 180f;
            projectile.rotation = (float)Math.Atan2(angle.Y, angle.X) + (float)Math.PI / 2f;
        }
        public override void AI()
        {
            Player player = Main.player[Projectile.owner];

            if (player.whoAmI == Main.myPlayer && player.active && !player.dead && player.GetModPlayer <FargoSoulsPlayer>().TrueEyes)
            {
                Projectile.timeLeft  = 2;
                Projectile.netUpdate = true;
            }

            if (Projectile.damage == 0)
            {
                Projectile.damage = (int)(60f * player.GetDamage(DamageClass.Summon).Additive);
            }

            //lighting effect?
            DelegateMethods.v3_1 = new Vector3(0.5f, 0.9f, 1f) * 1.5f;
            Utils.PlotTileLine(Projectile.Center, Projectile.Center + Projectile.velocity * 6f, 20f, DelegateMethods.CastLightOpen);
            Utils.PlotTileLine(Projectile.Left, Projectile.Right, 20f, DelegateMethods.CastLightOpen);
            Utils.PlotTileLine(player.Center, player.Center + player.velocity * 6f, 40f, DelegateMethods.CastLightOpen);
            Utils.PlotTileLine(player.Left, player.Right, 40f, DelegateMethods.CastLightOpen);

            if (Projectile.ai[0] >= 0 && Projectile.ai[0] < Main.maxNPCs) //has target
            {
                NPC minionAttackTargetNpc = Projectile.OwnerMinionAttackTargetNPC;
                if (minionAttackTargetNpc != null && Projectile.ai[0] != minionAttackTargetNpc.whoAmI && minionAttackTargetNpc.CanBeChasedBy())
                {
                    Projectile.ai[0] = minionAttackTargetNpc.whoAmI;
                }

                Projectile.localAI[0]++;
                NPC npc = Main.npc[(int)Projectile.ai[0]];
                if (npc.CanBeChasedBy())
                {
                    switch ((int)Projectile.ai[1])
                    {
                    case 0:     //true eye movement code
                        Vector2 newVel = npc.Center - Projectile.Center + new Vector2(-200f, -200f);
                        if (newVel != Vector2.Zero)
                        {
                            newVel.Normalize();
                            newVel *= 24f;
                            Projectile.velocity.X = (Projectile.velocity.X * 29 + newVel.X) / 30;
                            Projectile.velocity.Y = (Projectile.velocity.Y * 29 + newVel.Y) / 30;
                        }
                        if (Projectile.Distance(npc.Center) < 150f)
                        {
                            if (Projectile.Center.X < npc.Center.X)
                            {
                                Projectile.velocity.X -= 0.25f;
                            }
                            else
                            {
                                Projectile.velocity.X += 0.25f;
                            }

                            if (Projectile.Center.Y < npc.Center.Y)
                            {
                                Projectile.velocity.Y -= 0.25f;
                            }
                            else
                            {
                                Projectile.velocity.Y += 0.25f;
                            }
                        }

                        if (Projectile.localAI[0] > 60f)
                        {
                            if (Projectile.Distance(npc.Center) > 1500f)     //give up if too far
                            {
                                Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000);
                                Projectile.ai[1]      = 0f;
                                Projectile.localAI[1] = 0f;
                            }
                            Projectile.localAI[0] = 0f;
                            Projectile.ai[1]++;
                        }
                        break;

                    case 1:                                    //slow down
                        Projectile.velocity *= 0.9f;
                        if (Projectile.velocity.Length() < 1f) //stop, FIRE LASER
                        {
                            Projectile.velocity   = Vector2.Zero;
                            Projectile.localAI[0] = 0f;
                            Projectile.ai[1]++;
                        }
                        break;

                    case 2:     //shoot
                        if (Projectile.localAI[0] == 7f)
                        {
                            SoundEngine.PlaySound(SoundID.NPCDeath6 with {
                                Volume = 0.75f, Pitch = 0
                            }, Projectile.Center);
                            ShootBolts(npc);
                        }
                        else if (Projectile.localAI[0] == 14f)
                        {
                            ShootBolts(npc);
                        }
                        else if (Projectile.localAI[0] > 21f)
                        {
                            Projectile.localAI[0] = 0f;
                            Projectile.ai[1]++;
                        }
                        break;

                    default:
                        Projectile.ai[1] = 0f;
                        goto case 0;
                    }
                }
                else //forget target
                {
                    Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000);
                    Projectile.ai[1]      = 0f;
                    Projectile.localAI[0] = 0f;
                    Projectile.localAI[1] = 0f;
                }

                if (Projectile.rotation > 3.14159274101257)
                {
                    Projectile.rotation = Projectile.rotation - 6.283185f;
                }
                Projectile.rotation = Projectile.rotation <= -0.005 || Projectile.rotation >= 0.005 ? Projectile.rotation * 0.96f : 0.0f;
                if (++Projectile.frameCounter >= 4)
                {
                    Projectile.frameCounter = 0;
                    if (++Projectile.frame >= Main.projFrames[Projectile.type])
                    {
                        Projectile.frame = 0;
                    }
                }
                UpdatePupil();
            }
            else
            {
                if (Projectile.localAI[1]++ > 15f)
                {
                    Projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(Projectile, 1000);
                    Projectile.ai[1]      = 0f;
                    Projectile.localAI[0] = 0f;
                    Projectile.localAI[1] = 0f;
                }

                Vector2 vector2_1 = new Vector2(player.direction * -100f, 0); //vanilla movement code
                Vector2 vector2_2 = player.MountedCenter + vector2_1;
                float   num1      = Vector2.Distance(Projectile.Center, vector2_2);
                if (num1 > 1500) //teleport when out of range
                {
                    Projectile.Center = player.Center + vector2_1;
                }
                Vector2 vector2_3 = vector2_2 - Projectile.Center;
                float   num2      = 4f;
                if (num1 < num2)
                {
                    Projectile.velocity *= 0.25f;
                }
                if (vector2_3 != Vector2.Zero)
                {
                    if (vector2_3.Length() < num2)
                    {
                        Projectile.velocity = vector2_3;
                    }
                    else
                    {
                        Projectile.velocity = vector2_3 * 0.1f;
                    }
                }
                if (Projectile.velocity.Length() > 6) //when moving fast, rotate in direction of velocity
                {
                    float num3 = Projectile.velocity.ToRotation() + 1.570796f;
                    if (Math.Abs(Projectile.rotation - num3) >= 3.14159274101257)
                    {
                        Projectile.rotation = num3 >= Projectile.rotation ? Projectile.rotation + 6.283185f : Projectile.rotation - 6.283185f;
                    }
                    Projectile.rotation = (Projectile.rotation * 11f + num3) / 12f;
                    if (++Projectile.frameCounter >= 4)
                    {
                        Projectile.frameCounter = 0;
                        if (++Projectile.frame >= Main.projFrames[Projectile.type])
                        {
                            Projectile.frame = 0;
                        }
                    }
                }
                else //when moving slow, calm down
                {
                    if (Projectile.rotation > 3.14159274101257)
                    {
                        Projectile.rotation = Projectile.rotation - 6.283185f;
                    }
                    Projectile.rotation = Projectile.rotation <= -0.005 || Projectile.rotation >= 0.005 ? Projectile.rotation * 0.96f : 0f;
                    if (++Projectile.frameCounter >= 6)
                    {
                        Projectile.frameCounter = 0;
                        if (++Projectile.frame >= Main.projFrames[Projectile.type])
                        {
                            Projectile.frame = 0;
                        }
                    }
                }

                UpdatePupil();
            }

            /*Main.NewText("local0 " + localAI0.ToString()
             + " local1 " + localAI1.ToString()
             + " ai0 " + Projectile.ai[0].ToString()
             + " ai1 " + Projectile.ai[1].ToString());*/
        }
Beispiel #30
0
        public override void AI()
        {
            projectile.scale = 1;

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

            if (player.active && !player.dead && player.GetModPlayer <FargoPlayer>().Abominationn)
            {
                projectile.timeLeft = 2;
            }

            if (projectile.damage == 0)
            {
                projectile.damage = (int)(900f * player.minionDamage);
            }

            if (projectile.ai[0] >= 0 && projectile.ai[0] < Main.maxNPCs) //has target
            {
                NPC minionAttackTargetNpc = projectile.OwnerMinionAttackTargetNPC;
                if (minionAttackTargetNpc != null && projectile.ai[0] != minionAttackTargetNpc.whoAmI && minionAttackTargetNpc.CanBeChasedBy(projectile))
                {
                    projectile.ai[0] = minionAttackTargetNpc.whoAmI;
                }

                NPC npc = Main.npc[(int)projectile.ai[0]];
                if (npc.CanBeChasedBy(projectile))
                {
                    projectile.direction = projectile.spriteDirection = projectile.Center.X > npc.Center.X ? 1 : -1;
                    Vector2 targetPos = npc.Center + projectile.DirectionFrom(npc.Center) * 250;
                    if (projectile.Distance(targetPos) > 50)
                    {
                        Movement(targetPos, 1f);
                    }
                    if (++projectile.localAI[0] > 15)
                    {
                        projectile.localAI[0] = 0;
                        if (projectile.owner == Main.myPlayer)
                        {
                            Projectile.NewProjectile(projectile.Center, projectile.velocity + projectile.DirectionTo(npc.Center) * 30, mod.ProjectileType("AbominationnScythe"), projectile.damage, projectile.knockBack / 2, projectile.owner, npc.whoAmI);
                        }
                    }
                }
                else //forget target
                {
                    projectile.ai[0]     = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1500);
                    projectile.netUpdate = true;
                }
            }
            else //no target
            {
                projectile.direction = projectile.spriteDirection = projectile.Center.X > player.Center.X ? 1 : -1;

                Vector2 targetPos = player.Center;
                if (player.velocity.X > 0)
                {
                    targetPos.X -= 100;
                }
                else if (player.velocity.X < 0)
                {
                    targetPos.X += 100;
                }
                else
                {
                    targetPos.X += 100 * -player.direction;
                }
                targetPos.Y -= 50;

                if (projectile.Distance(targetPos) > 3000)
                {
                    projectile.Center = player.Center;
                }
                else if (projectile.Distance(targetPos) > 50)
                {
                    Movement(targetPos, 1f);
                }

                if (++projectile.localAI[1] > 6)
                {
                    projectile.localAI[1] = 0;
                    projectile.ai[0]      = FargoSoulsUtil.FindClosestHostileNPCPrioritizingMinionFocus(projectile, 1500);
                    if (projectile.ai[0] != -1)
                    {
                        projectile.netUpdate = true;
                    }
                }
            }

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