private void SpawnRazorbladeRing(int max, float speed, float rotationModifier)
        {
            float   rotation = 2f * (float)Math.PI / max;
            Vector2 vel      = Projectile.velocity;

            vel.Normalize();
            vel *= speed;
            int type = ModContent.ProjectileType <AbomScytheFriendly>();

            for (int i = 0; i < max; i++)
            {
                vel = vel.RotatedBy(rotation);
                if (Projectile.DamageType == DamageClass.Summon)
                {
                    FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel, type, Projectile.originalDamage / 3,
                                                       Projectile.knockBack / 4f, Projectile.owner, rotationModifier * Projectile.spriteDirection);
                }
                else
                {
                    int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel, type, Projectile.damage / 3,
                                                     Projectile.knockBack / 4f, Projectile.owner, rotationModifier * Projectile.spriteDirection);
                    if (p != Main.maxProjectiles)
                    {
                        Main.projectile[p].DamageType = Projectile.DamageType;
                    }
                }
            }
        }
        public override void AI()
        {
            Player player = Main.player[Projectile.owner];

            Projectile.timeLeft = 2;

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

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

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

            //Main.NewText(Projectile.ai[0].ToString() + " " + Projectile.ai[1].ToString() + " " + Projectile.localAI[0].ToString() + " " + Projectile.localAI[1].ToString());
        }
        public static void PalmEffect(Player player)
        {
            FargoSoulsPlayer modPlayer = player.GetModPlayer <FargoSoulsPlayer>();

            modPlayer.PalmEnchantActive = true;

            if (player.GetToggleValue("Palm") && player.whoAmI == Main.myPlayer && modPlayer.DoubleTap)
            {
                Vector2 mouse = Main.MouseWorld;

                if (player.ownedProjectileCounts[ModContent.ProjectileType <PalmTreeSentry>()] > 0)
                {
                    for (int i = 0; i < Main.maxProjectiles; i++)
                    {
                        Projectile proj = Main.projectile[i];

                        if (proj.type == ModContent.ProjectileType <PalmTreeSentry>() && proj.owner == player.whoAmI)
                        {
                            proj.Kill();
                        }
                    }
                }

                FargoSoulsUtil.NewSummonProjectile(player.GetSource_Misc(""), mouse - 10 * Vector2.UnitY, Vector2.Zero, ModContent.ProjectileType <PalmTreeSentry>(), modPlayer.WoodForce ? 45 : 15, 0f, player.whoAmI);
            }
        }
        public override void Update(Player player, ref int buffIndex)
        {
            if (player.whoAmI == Main.myPlayer)
            {
                FargoSoulsPlayer fargoPlayer = player.GetModPlayer <FargoSoulsPlayer>();

                if (player.GetToggleValue("MasoAbom"))
                {
                    fargoPlayer.AbomMinion = true;
                    if (player.ownedProjectileCounts[ModContent.ProjectileType <AbomMinion>()] < 1)
                    {
                        FargoSoulsUtil.NewSummonProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType <AbomMinion>(), 900, 10f, player.whoAmI, -1);
                    }
                }

                if (player.GetToggleValue("MasoRing"))
                {
                    fargoPlayer.PhantasmalRing = true;
                    if (player.ownedProjectileCounts[ModContent.ProjectileType <PhantasmalRing>()] < 1)
                    {
                        FargoSoulsUtil.NewSummonProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType <PhantasmalRing>(), 1700, 0f, player.whoAmI);
                    }
                }
            }
        }
 public override void Update(Player player, ref int buffIndex)
 {
     player.GetModPlayer <FargoSoulsPlayer>().PungentEyeballMinion = true;
     if (player.whoAmI == Main.myPlayer && player.ownedProjectileCounts[ModContent.ProjectileType <Projectiles.Minions.PungentEyeball>()] < 1)
     {
         FargoSoulsUtil.NewSummonProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType <Projectiles.Minions.PungentEyeball>(), 50, 0f, player.whoAmI);
     }
 }
 public override void Update(Player player, ref int buffIndex)
 {
     player.buffTime[buffIndex] = 18000;
     player.GetModPlayer <PatreonPlayer>().Crimetroid = true;
     if (player.whoAmI == Main.myPlayer && player.ownedProjectileCounts[ModContent.ProjectileType <Crimetroid>()] < 1)
     {
         FargoSoulsUtil.NewSummonProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType <Crimetroid>(), 1, 1f, player.whoAmI);
     }
 }
        public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
        {
            if (player.altFunctionUse == 2)
            {
                FargoSoulsUtil.NewSummonProjectile(source, position, velocity, type, Item.damage, knockback, player.whoAmI);
                return(false);
            }

            return(base.Shoot(player, source, position, velocity, type, damage, knockback));
        }
Beispiel #8
0
        public override void Update(Player player, ref int buffIndex)
        {
            player.GetModPlayer <FargoSoulsPlayer>().MagicalBulb = true;
            const int damage = 60;

            if (player.whoAmI == Main.myPlayer && player.ownedProjectileCounts[ModContent.ProjectileType <Projectiles.Minions.PlanterasChild>()] < 1)
            {
                FargoSoulsUtil.NewSummonProjectile(player.GetSource_Buff(buffIndex), player.Center, -Vector2.UnitY, ModContent.ProjectileType <Projectiles.Minions.PlanterasChild>(), damage, 3f, player.whoAmI);
            }
        }
Beispiel #9
0
        public override void Update(Player player, ref int buffIndex)
        {
            player.GetModPlayer <FargoSoulsPlayer>().LunarCultist = true;
            const int damage = 80;

            if (player.whoAmI == Main.myPlayer && player.ownedProjectileCounts[ModContent.ProjectileType <Projectiles.Minions.LunarCultist>()] < 1)
            {
                FargoSoulsUtil.NewSummonProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType <Projectiles.Minions.LunarCultist>(), damage, 2f, player.whoAmI, -1f);
            }
        }
Beispiel #10
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]);
                    }
                }
            }
        }
        public override void Kill(int timeleft)
        {
            if (!Main.dedServ && Main.LocalPlayer.active)
            {
                Main.LocalPlayer.GetModPlayer <FargoSoulsPlayer>().Screenshake = 30;
            }

            MakeDust();

            SoundEngine.PlaySound(SoundID.NPCDeath6, Projectile.Center);
            SoundEngine.PlaySound(SoundID.Item92, Projectile.Center);

            if (Projectile.owner == Main.myPlayer)
            {
                Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, -1, -14);
            }

            if (Projectile.owner == Main.myPlayer)
            {
                float minionSlotsUsed = 0;
                for (int i = 0; i < Main.maxProjectiles; i++)
                {
                    if (Main.projectile[i].active && !Main.projectile[i].hostile && Main.projectile[i].owner == Projectile.owner && Main.projectile[i].minionSlots > 0)
                    {
                        minionSlotsUsed += Main.projectile[i].minionSlots;
                    }
                }

                float modifier = Main.player[Projectile.owner].maxMinions - minionSlotsUsed;
                if (modifier < 0)
                {
                    modifier = 0;
                }
                if (modifier > 12)
                {
                    modifier = 12;
                }

                int max = (int)modifier + 4;
                for (int i = 0; i < max; i++)
                {
                    Vector2 target       = 600 * -Vector2.UnitY.RotatedBy(2 * Math.PI / max * i + Projectile.localAI[1]);
                    Vector2 speed        = 2 * target / 90;
                    float   acceleration = -speed.Length() / 90;
                    float   rotation     = speed.ToRotation() + (float)Math.PI / 2;
                    FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, speed, ModContent.ProjectileType <SparklingLoveEnergyHeart>(),
                                                       Projectile.originalDamage, Projectile.knockBack, Projectile.owner, rotation, acceleration);

                    FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, 14f * Vector2.UnitY.RotatedBy(2 * Math.PI / max * (i + 0.5) + Projectile.localAI[1]),
                                                       ModContent.ProjectileType <SparklingLoveHeart2>(), Projectile.originalDamage, Projectile.knockBack,
                                                       Projectile.owner, -1, 45);
                }
            }
        }
 public override void Update(Player player, ref int buffIndex)
 {
     player.GetModPlayer <FargoSoulsPlayer>().RainbowSlime = true;
     if (player.whoAmI == Main.myPlayer)
     {
         if (player.ownedProjectileCounts[ModContent.ProjectileType <Projectiles.Minions.RainbowSlime>()] < 1)
         {
             FargoSoulsUtil.NewSummonProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType <Projectiles.Minions.RainbowSlime>(), 35, 3f, player.whoAmI);
         }
     }
 }
 public override void Update(Player player, ref int buffIndex)
 {
     player.GetModPlayer <FargoSoulsPlayer>().MiniSaucer = true;
     if (player.whoAmI == Main.myPlayer)
     {
         const int damage = 50;
         if (player.ownedProjectileCounts[ModContent.ProjectileType <MiniSaucer>()] < 1)
         {
             FargoSoulsUtil.NewSummonProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType <MiniSaucer>(), damage, 3f, player.whoAmI);
         }
     }
 }
Beispiel #14
0
 public override void Update(Player player, ref int buffIndex)
 {
     player.GetModPlayer <FargoSoulsPlayer>().SuperFlocko = true;
     if (player.whoAmI == Main.myPlayer)
     {
         const int damage = 45;
         if (player.ownedProjectileCounts[ModContent.ProjectileType <Projectiles.Minions.SuperFlocko>()] < 1)
         {
             FargoSoulsUtil.NewSummonProjectile(player.GetSource_Buff(buffIndex), player.Center, new Vector2(0f, -10f), ModContent.ProjectileType <Projectiles.Minions.SuperFlocko>(), damage, 4f, player.whoAmI);
         }
     }
 }
Beispiel #15
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;
            }
        }
        private void ShootBolts(NPC npc)
        {
            Vector2 spawn = Projectile.Center - Vector2.UnitY * 6f;
            Vector2 vel   = npc.Center + npc.velocity * 15f - spawn;

            if (vel != Vector2.Zero)
            {
                vel.Normalize();
                vel *= 8f;
                for (int i = -1; i <= 1; i++)
                {
                    FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), spawn, vel.RotatedBy(Math.PI / 24 * i), ModContent.ProjectileType <PhantasmalBoltTrueEye>(),
                                                       Projectile.originalDamage / 3 * 7, 6f, Projectile.owner);
                }
            }
        }
        public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
        {
            damage = (int)(damage / 4.0 * 1.3);

            float minionSlotsUsed = 0;

            for (int i = 0; i < Main.maxProjectiles; i++)
            {
                if (Main.projectile[i].active && !Main.projectile[i].hostile && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].minionSlots > 0)
                {
                    minionSlotsUsed += Main.projectile[i].minionSlots;
                }
            }

            float modifier = player.maxMinions - minionSlotsUsed;

            if (modifier < 1)
            {
                modifier = 1;
            }
            if (modifier > 7)
            {
                modifier = 7;
            }

            float spread = MathHelper.ToRadians(60f / 3.5f);

            if (modifier % 2 == 0)
            {
                Vector2 baseSpeed = velocity.RotatedBy(spread * (-modifier / 2 + 0.5f)); //half offset for v spread
                for (int i = 0; i < modifier; i++)
                {
                    FargoSoulsUtil.NewSummonProjectile(source, position, baseSpeed.RotatedBy(spread * (i + Main.rand.NextFloat(-0.5f, 0.5f))), type, Item.damage, knockback, player.whoAmI);
                }
            }
            else
            {
                Vector2 baseSpeed = velocity;
                int     max       = (int)modifier / 2;
                for (int i = -max; i <= max; i++)
                {
                    FargoSoulsUtil.NewSummonProjectile(source, position, baseSpeed.RotatedBy(spread * (i + Main.rand.NextFloat(-0.5f, 0.5f))), type, Item.damage, knockback, player.whoAmI);
                }
            }

            return(false);
        }
Beispiel #18
0
        public override void AI()
        {
            Player player = Main.player[Projectile.owner];

            if (player.whoAmI == Main.myPlayer && 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.owner == Main.myPlayer)
            {
                Projectile.rotation = (Main.MouseWorld - Projectile.Center).ToRotation();

                if (--Projectile.localAI[0] < 0f)
                {
                    if (player.controlUseItem && player.HeldItem.damage > 0 && player.HeldItem.pick == 0 && player.HeldItem.hammer == 0 && player.HeldItem.axe == 0)
                    {
                        Projectile.localAI[0] = player.GetModPlayer <FargoSoulsPlayer>().MasochistSoul ? 15f : 30f;
                        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.localAI[0] = 0f;
                    }
                }

                if (++Projectile.localAI[1] > 20f) //needed for rotation sync in multi
                {
                    Projectile.localAI[1] = 0f;
                    Projectile.netUpdate  = true;
                }

                Projectile.rotation += (float)Math.PI;
            }
        }
Beispiel #19
0
        public override void Kill(int timeLeft)
        {
            FargoSoulsUtil.HeartDust(Projectile.Center, Projectile.rotation + MathHelper.PiOver2);

            /*for (int i = 0; i < 10; i++)
             * {
             *  int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 86, 0f, 0f, 0, default(Color), 2f);
             *  Main.dust[d].noGravity = true;
             *  Main.dust[d].velocity *= 8f;
             * }*/

            if (Projectile.owner == Main.myPlayer)
            {
                FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.UnitX.RotatedBy(Projectile.rotation),
                                                   ModContent.ProjectileType <SparklingLoveDeathray2>(), Projectile.originalDamage, Projectile.knockBack, Projectile.owner);
                FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.UnitX.RotatedBy(Projectile.rotation + (float)Math.PI),
                                                   ModContent.ProjectileType <SparklingLoveDeathray2>(), Projectile.originalDamage, Projectile.knockBack, Projectile.owner);

                FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), new Vector2(Projectile.localAI[0], Projectile.localAI[1]), Vector2.UnitX.RotatedBy(Projectile.rotation - (float)Math.PI / 2),
                                                   ModContent.ProjectileType <SparklingLoveDeathray2>(), Projectile.originalDamage, Projectile.knockBack, Projectile.owner);
            }
        }
        public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
        {
            player.AddBuff(ModContent.BuffType <PrimeMinionBuff>(), 2);
            Vector2 spawnPos        = Main.MouseWorld;
            float   usedminionslots = 0;
            var     minions         = Main.projectile.Where(x => x.minionSlots > 0 && x.owner == player.whoAmI && x.active);

            foreach (Projectile minion in minions)
            {
                usedminionslots += minion.minionSlots;
            }
            if (usedminionslots < player.maxMinions)
            {
                if (player.ownedProjectileCounts[type] == 0) //only spawn brain minion itself when the player doesnt have any, and if minion slots aren't maxxed out
                {
                    FargoSoulsUtil.NewSummonProjectile(source, spawnPos, Vector2.Zero, type, Item.damage, knockback, player.whoAmI);
                }

                if (++counter >= 4)
                {
                    counter = 0;
                }

                int limbType;
                switch (counter)
                {
                case 0: limbType = ModContent.ProjectileType <PrimeMinionVice>(); break;

                case 1: limbType = ModContent.ProjectileType <PrimeMinionSaw>(); break;

                case 2: limbType = ModContent.ProjectileType <PrimeMinionLaserGun>(); break;

                default: limbType = ModContent.ProjectileType <PrimeMinionCannon>(); break;
                }

                FargoSoulsUtil.NewSummonProjectile(source, spawnPos, Main.rand.NextVector2Circular(10, 10), limbType, Item.damage, knockback, player.whoAmI);
            }
            return(false);
        }
        public override void Kill(int timeLeft)
        {
            const int   dustMax = 25;
            const float speed   = 6;

            for (int i = 0; i < dustMax; i++)
            {
                int d = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 70, Scale: 3.5f);
                Main.dust[d].velocity *= speed;
                Main.dust[d].noGravity = true;
            }

            if (Projectile.owner == Main.myPlayer)
            {
                Vector2   vel = 30f * Vector2.Normalize(Projectile.velocity);
                const int max = 6;
                for (int i = 0; i < max; i++)
                {
                    FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel.RotatedBy(MathHelper.TwoPi / max * i), ModContent.ProjectileType <AbomMinionSickle>(), Projectile.originalDamage, Projectile.knockBack, Projectile.owner, 30);
                }
            }
        }
Beispiel #22
0
        public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
        {
            player.AddBuff(ModContent.BuffType <BigBrainMinion>(), 2);
            Vector2 spawnPos = player.Center - Main.MouseWorld;

            if (player.ownedProjectileCounts[type] == 0)
            {
                FargoSoulsUtil.NewSummonProjectile(source, player.Center, Vector2.Zero, type, Item.damage, knockback, player.whoAmI, 0, spawnPos.ToRotation());
            }
            else
            {
                float usedslots = 0;
                int   brain     = -1;
                for (int i = 0; i < Main.projectile.Length; i++)
                {
                    Projectile proj = Main.projectile[i];
                    if (proj.owner == player.whoAmI && proj.minionSlots > 0 && proj.active)
                    {
                        usedslots += proj.minionSlots;
                        if (proj.type == type)
                        {
                            brain = i;
                            if (usedslots < player.maxMinions)
                            {
                                proj.minionSlots++;
                            }
                        }
                    }
                }

                if (player.GetModPlayer <FargoSoulsPlayer>().TikiMinion&& usedslots > player.GetModPlayer <FargoSoulsPlayer>().actualMinions&& FargoSoulsUtil.ProjectileExists(brain, type) != null)
                {
                    Main.projectile[brain].GetGlobalProjectile <Projectiles.FargoSoulsGlobalProjectile>().tikiMinion = true;
                }
            }
            return(false);
        }
Beispiel #23
0
        public override bool PreAI()
        {
            Player player = Main.player[Projectile.owner];

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

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

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

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

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

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

                        Vector2 dashVel = Projectile.DirectionTo(targetNPC.Center);
                        Projectile.velocity        = Vector2.Lerp(Projectile.velocity, dashVel * 18, 0.03f);
                        Projectile.rotation        = 0;
                        Projectile.tileCollide     = false;
                        Projectile.direction       = Math.Sign(Projectile.velocity.X);
                        Projectile.spriteDirection = -Projectile.direction;
                        return(false);
                    }
                }
            }
            trailbehind            = false;
            Projectile.tileCollide = true;
            return(true);
        }
        public override void AI()
        {
            Player           player    = Main.player[Projectile.owner];
            FargoSoulsPlayer modPlayer = player.GetModPlayer <FargoSoulsPlayer>();

            if ((int)Main.time % 120 == 0)
            {
                Projectile.netUpdate = true;
            }

            int num1038 = 30;

            bool    flag67      = false;
            Vector2 value67     = Vector2.Zero;
            Vector2 arg_2D865_0 = Vector2.Zero;
            float   num1052     = 0f;

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

            int byIdentity = FargoSoulsUtil.GetProjectileByIdentity(Projectile.owner, (int)Projectile.ai[0], Projectile.type, ModContent.ProjectileType <DestroyerHead2>());

            if (byIdentity >= 0 && Main.projectile[byIdentity].active)
            {
                flag67  = true;
                value67 = Main.projectile[byIdentity].Center;
                Vector2 arg_2D957_0 = Main.projectile[byIdentity].velocity;
                num1052 = Main.projectile[byIdentity].rotation;
                float num1053     = MathHelper.Clamp(Main.projectile[byIdentity].scale, 0f, 50f);
                int   arg_2D9AD_0 = Main.projectile[byIdentity].alpha;
                if (arg_2D9AD_0 == 0)
                {
                    Projectile.alpha -= 84;
                    if (Projectile.alpha < 0)
                    {
                        Projectile.alpha = 0;
                    }
                }
                Main.projectile[byIdentity].localAI[0] = Projectile.localAI[0] + 1f;
                if (Main.projectile[byIdentity].type != ModContent.ProjectileType <DestroyerHead2>())
                {
                    Main.projectile[byIdentity].localAI[1] = Projectile.identity;
                }
            }

            if (!flag67)
            {
                return;
            }

            //Projectile.alpha -= 42;
            //if (Projectile.alpha < 0) Projectile.alpha = 0;
            Projectile.velocity = Vector2.Zero;
            Vector2 vector134 = value67 - Projectile.Center;

            if (num1052 != Projectile.rotation)
            {
                float num1056 = MathHelper.WrapAngle(num1052 - Projectile.rotation);
                vector134 = vector134.RotatedBy(num1056 * 0.1f, default(Vector2));
            }

            Projectile.rotation = vector134.ToRotation() + 1.57079637f;
            Projectile.position = Projectile.Center;
            Projectile.width    = Projectile.height = (int)(num1038 * Projectile.scale);
            Projectile.Center   = Projectile.position;
            if (vector134 != Vector2.Zero)
            {
                Projectile.Center = value67 - Vector2.Normalize(vector134) * 36;
            }
            Projectile.spriteDirection = vector134.X > 0f ? 1 : -1;

            if (--attackTimer <= 0)
            {
                attackTimer = Main.rand.Next(90) + 90;
            }

            if (attackTimer == 1)
            {
                if (Projectile.owner == Main.myPlayer)
                {
                    int         selectedTarget = -1; //pick target
                    const float maxRange       = 750f;
                    for (int i = 0; i < Main.maxNPCs; i++)
                    {
                        if (Main.npc[i].CanBeChasedBy(Projectile) && Collision.CanHit(Projectile.Center, 0, 0, Main.npc[i].Center, 0, 0))
                        {
                            if (Projectile.Distance(Main.npc[i].Center) <= maxRange && Main.rand.NextBool()) //random because destroyer
                            {
                                selectedTarget = i;
                            }
                        }
                    }

                    if (selectedTarget != -1) //shoot
                    {
                        FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.DirectionTo(Main.npc[selectedTarget].Center).RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4)),
                                                           ModContent.ProjectileType <DarkStarHomingFriendly>(), Projectile.originalDamage, Projectile.knockBack, Projectile.owner, selectedTarget);
                    }
                }
            }
        }
Beispiel #25
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];
            FargoSoulsPlayer modPlayer = player.GetModPlayer <FargoSoulsPlayer>();

            if (player.active && !player.dead && modPlayer.PalmEnchantActive)
            {
                Projectile.timeLeft = 2;
            }

            Projectile.velocity.Y = Projectile.velocity.Y + 0.2f;
            if (Projectile.velocity.Y > 16f)
            {
                Projectile.velocity.Y = 16f;
            }

            Projectile.ai[1] += 1f;

            int attackRate = 45;

            if (modPlayer.WoodForce || modPlayer.WizardEnchantActive)
            {
                attackRate = 30;
            }

            if (Projectile.ai[1] >= attackRate)
            {
                float num      = 2000f;
                int   npcIndex = -1;
                for (int i = 0; i < 200; i++)
                {
                    float dist = Vector2.Distance(Projectile.Center, Main.npc[i].Center);

                    if (dist < num && dist < 300 && Main.npc[i].CanBeChasedBy(Projectile, false))
                    {
                        npcIndex = i;
                        num      = dist;
                    }
                }

                if (npcIndex != -1)
                {
                    NPC target = Main.npc[npcIndex];

                    if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, target.position, target.width, target.height))
                    {
                        Vector2 velocity = Vector2.Normalize(target.Center - Projectile.Center) * 10;

                        int p = FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ProjectileID.SeedlerNut, Projectile.originalDamage, 2, Projectile.owner);
                        if (p != Main.maxProjectiles)
                        {
                            Main.projectile[p].DamageType = DamageClass.Summon;
                        }
                    }
                }
                Projectile.ai[1] = 0f;

                //kill if too far away
                if (Vector2.Distance(Main.player[Projectile.owner].Center, Projectile.Center) > 2000)
                {
                    Projectile.Kill();
                }
            }
        }
Beispiel #27
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 #28
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();
        }
Beispiel #29
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 #30
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;
            }

            int head = -1;

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

                bool targetting            = false;
                NPC  targetnpc             = null;
                NPC  minionAttackTargetNpc = Projectile.OwnerMinionAttackTargetNPC;
                if (minionAttackTargetNpc != null && minionAttackTargetNpc.CanBeChasedBy((object)this, false))
                {
                    Vector2 distancetotarget = minionAttackTargetNpc.Center - Projectile.Center;
                    Vector2 headtoTarget     = minionAttackTargetNpc.Center - Main.projectile[head].Center;
                    if (distancetotarget.Length() < 1000 && headtoTarget.Length() < 400)
                    {
                        targetnpc  = minionAttackTargetNpc;
                        targetting = true;
                    }
                }
                else if (!targetting)
                {
                    float distancemax = 1000;
                    for (int index = 0; index < 200; ++index)
                    {
                        if (Main.npc[index].CanBeChasedBy((object)this, false))
                        {
                            Vector2 distancetotarget = Main.npc[index].Center - Projectile.Center;
                            Vector2 headtotarget     = Main.npc[index].Center - Main.projectile[head].Center;
                            if (distancetotarget.Length() < distancemax && headtotarget.Length() < 400)
                            {
                                distancemax = distancetotarget.Length();
                                targetnpc   = Main.npc[index];
                                targetting  = true;
                            }
                        }
                    }
                }

                float movespeed = Math.Max(Projectile.Distance(Main.projectile[head].Center) / 40f, 14f);

                if (Projectile.Distance(Main.projectile[head].Center) > 64)
                {
                    Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.DirectionTo(Main.projectile[head].Center) * movespeed, 0.04f);
                }
                Projectile.rotation  = 0;
                Projectile.direction = Projectile.spriteDirection = Main.projectile[head].spriteDirection;

                if (targetting)
                {
                    Projectile.rotation  = Projectile.DirectionTo(targetnpc.Center).ToRotation();
                    Projectile.direction = Projectile.spriteDirection = 1;

                    if (++Projectile.localAI[0] > 22)
                    {
                        Projectile.localAI[0] = -Main.rand.Next(20);
                        if (Projectile.owner == Main.myPlayer)
                        {
                            int p = FargoSoulsUtil.NewSummonProjectile(Projectile.GetSource_FromThis(), Projectile.Center, 10f * Projectile.DirectionTo(targetnpc.Center), ProjectileID.MiniRetinaLaser, Projectile.originalDamage, Projectile.knockBack, Projectile.owner);
                            if (p != Main.maxProjectiles)
                            {
                                Main.projectile[p].usesIDStaticNPCImmunity = false;
                                Main.projectile[p].usesLocalNPCImmunity    = false;
                            }
                        }
                    }
                }

                Projectile.position += Main.projectile[head].velocity * 0.8f;
            }
        }