public Vector2 TipOffset => 9f *Projectile.velocity *Projectile.scale;   //offset to look like is at tip proper

        public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
        {
            if (Projectile.Distance(FargoSoulsUtil.ClosestPointInHitbox(targetHitbox, Projectile.Center)) < TipOffset.Length() * 2)
            {
                return(true);
            }

            return(base.Colliding(projHitbox, targetHitbox));
        }
        public override bool PreAI(NPC npc)
        {
            if (!npc.HasValidTarget)
            {
                npc.velocity.Y -= 1f;
            }

            switch ((int)npc.ai[0])
            {
            case 0:     //between attacks
                if (npc.GetGlobalNPC <FargoSoulsGlobalNPC>().BloodDrinker)
                {
                    if (npc.HasValidTarget)
                    {
                        float modifier = npc.Distance(Main.player[npc.target].Center) > 900 ? 0.3f : 0.1f;
                        npc.velocity += modifier * npc.DirectionTo(Main.player[npc.target].Center);
                    }
                    npc.position += npc.velocity;
                }
                break;

            case 1:     //spinning around player, dashes at ai1=90, ends at ai1=270
                if (npc.ai[1] <= 90)
                {
                    if (npc.GetGlobalNPC <FargoSoulsGlobalNPC>().BloodDrinker)
                    {
                        npc.ai[1]++;     //less startup
                    }
                }
                else
                {
                    if (npc.HasValidTarget)
                    {
                        npc.position += Main.player[npc.target].position - Main.player[npc.target].oldPosition;
                    }

                    //spawn thorn missiles on outside of spin
                    if (npc.ai[1] % 2 == 0 && npc.Distance(FargoSoulsUtil.ClosestPointInHitbox(Main.player[npc.target], npc.Center)) > 30)
                    {
                        float rotation = npc.velocity.ToRotation();
                        float diff     = MathHelper.WrapAngle(rotation - npc.DirectionTo(Main.player[npc.target].Center).ToRotation());
                        rotation += MathHelper.PiOver2 * System.Math.Sign(diff);

                        Vector2 vel         = Vector2.UnitX.RotatedBy(rotation);
                        Vector2 spawnOffset = 100f * vel;

                        if (Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center + spawnOffset, vel, ModContent.ProjectileType <BloodThornMissile>(), FargoSoulsUtil.ScaledProjectileDamage(npc.damage), 0f, Main.myPlayer);
                        }
                    }
                }
                break;

            case 2:     //spit blood on you, shoot repeatedly after ai=90, ends at ai1=180
                if (npc.ai[1] < 90 && npc.GetGlobalNPC <FargoSoulsGlobalNPC>().BloodDrinker)
                {
                    npc.ai[1]++;
                }

                npc.ai[1] += 0.5f;
                break;

            case 3:     //glowing, spawning blood squids, ends at ai1=180
            {
                void Checks()
                {
                    if (npc.ai[1] == 60)
                    {
                        SoundEngine.PlaySound(SoundID.Roar, npc.Center);
                    }

                    if (npc.ai[1] >= 120 && npc.ai[1] % 15 == 5) //when done
                    {
                        for (int i = 0; i < 10; i++)             //spawn blood spikes around player
                        {
                            Vector2 target   = Main.player[npc.target].Center + Main.rand.NextVector2Circular(64, 16);
                            Vector2 spawnPos = Main.player[npc.target].Bottom + new Vector2(Main.rand.NextFloat(-256, 256), Main.rand.NextFloat(64));
                            spawnPos.Y += 250;

                            for (int j = 0; j < 40; j++)
                            {
                                Tile tile = Framing.GetTileSafely(spawnPos);
                                if (tile.HasUnactuatedTile && (Main.tileSolid[tile.TileType] || Main.tileSolidTop[tile.TileType]))
                                {
                                    break;
                                }
                                spawnPos.Y += 16;
                            }

                            Vector2 vel = Vector2.Normalize(target - spawnPos);

                            if (Main.netMode != NetmodeID.MultiplayerClient)
                            {
                                Projectile.NewProjectile(npc.GetSource_FromThis(), spawnPos + vel * 50, 0.6f * vel, ModContent.ProjectileType <BloodThornMissile>(), FargoSoulsUtil.ScaledProjectileDamage(npc.damage), 0f, Main.myPlayer);

                                Projectile.NewProjectile(npc.GetSource_FromThis(), spawnPos, 16f * vel.RotatedByRandom(MathHelper.ToRadians(10)), ProjectileID.SharpTears, FargoSoulsUtil.ScaledProjectileDamage(npc.damage), 0f, Main.myPlayer, 0f, Main.rand.NextFloat(0.5f, 1f));
                            }
                        }
                    }
                }

                Checks();

                if (npc.GetGlobalNPC <FargoSoulsGlobalNPC>().BloodDrinker&& npc.ai[1] % 10 != 0)
                {
                    npc.ai[1]++;
                    Checks();
                }
            }
            break;

            default:
                break;
            }

            //suck in and kill blood squids
            foreach (NPC n in Main.npc.Where(n => n.active && !n.boss && n.lifeMax <= 1500 && n.life < n.lifeMax * 0.6 && npc.Distance(n.Center) < 600 && Collision.CanHitLine(n.Center, 0, 0, npc.Center, 0, 0)))
            {
                if (npc.Distance(n.Center) < npc.width / 4)
                {
                    npc.AddBuff(ModContent.BuffType <BloodDrinker>(), 360);

                    //int heal = n.life;
                    //npc.life += heal;
                    //if (npc.life > npc.lifeMax)
                    //    npc.life = npc.lifeMax;
                    //CombatText.NewText(npc.Hitbox, CombatText.HealLife, heal, true);

                    n.life = 0;
                    n.HitEffect();
                    n.checkDead();
                    n.active = false;
                    CombatText.NewText(n.Hitbox, Color.Red, n.life, true);
                }
                else
                {
                    n.position -= n.velocity;
                    n.position += npc.velocity / 2;
                    n.position += n.DirectionTo(npc.Center) * n.velocity.Length() * 2f;
                }
            }

            return(base.PreAI(npc));
        }
示例#3
0
        public override void AI()
        {
            Player      player    = Main.player[projectile.owner];
            FargoPlayer modPlayer = player.GetModPlayer <FargoPlayer>();

            projectile.timeLeft++;

            if (player.dead || !player.active || !modPlayer.SnowEnchant)
            {
                projectile.Kill();
            }

            if (player == Main.LocalPlayer)
            {
                projectile.Center = Main.MouseWorld;

                if (!player.GetToggleValue("Snow"))
                {
                    projectile.Kill();
                }
            }

            //dust
            int dist = 50;

            if (modPlayer.NatureForce)
            {
                dist = 100;
            }


            for (int i = 0; i < 15; i++)
            {
                Vector2 offset = new Vector2();
                double  angle  = Main.rand.NextDouble() * 2d * Math.PI;
                offset.X += (float)(Math.Sin(angle) * Main.rand.Next(dist + 1));
                offset.Y += (float)(Math.Cos(angle) * Main.rand.Next(dist + 1));
                Dust dust = Main.dust[Dust.NewDust(
                                          projectile.Center + offset - new Vector2(4, 4), 0, 0,
                                          76, 0, 0, 100, Color.White, .75f)];

                dust.noGravity = true;
            }

            //for (int i = 0; i < 20; i++)
            //{
            //    Vector2 offset = new Vector2();
            //    double angle = Main.rand.NextDouble() * 2d * Math.PI;
            //    offset.X += (float)(Math.Sin(angle) * dist);
            //    offset.Y += (float)(Math.Cos(angle) * dist);
            //    if (!Collision.SolidCollision(projectile.Center + offset - new Vector2(4, 4), 0, 0))
            //    {
            //        Dust dust = Main.dust[Dust.NewDust(
            //          projectile.Center + offset - new Vector2(4, 4), 0, 0,
            //          76, 0, 0, 100, Color.White, 1f
            //          )];
            //        dust.velocity = projectile.velocity;
            //        dust.noGravity = true;
            //    }
            //}



            for (int i = 0; i < Main.maxProjectiles; i++)
            {
                Projectile proj = Main.projectile[i];


                if (proj.active && proj.hostile && proj.damage > 0 && projectile.Distance(FargoSoulsUtil.ClosestPointInHitbox(proj, projectile.Center)) < dist && FargoSoulsUtil.CanDeleteProjectile(proj))
                {
                    FargoGlobalProjectile globalProj = proj.GetGlobalProjectile <FargoGlobalProjectile>();
                    globalProj.ChilledProj  = true;
                    globalProj.ChilledTimer = 15;
                    projectile.netUpdate    = true;
                }
            }


            for (int i = 0; i < Main.maxNPCs; i++)
            {
                NPC npc = Main.npc[i];

                if (npc.active && !npc.friendly && npc.damage > 0 && projectile.Distance(FargoSoulsUtil.ClosestPointInHitbox(npc, projectile.Center)) < dist && !npc.dontTakeDamage)
                {
                    npc.GetGlobalNPC <FargoSoulsGlobalNPC>().SnowChilled      = true;
                    npc.GetGlobalNPC <FargoSoulsGlobalNPC>().SnowChilledTimer = 15;
                    npc.netUpdate = true;
                }
            }
        }
 public override bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox)
 {
     return(Projectile.Distance(FargoSoulsUtil.ClosestPointInHitbox(targetHitbox, Projectile.Center)) < Math.Min(Projectile.width, Projectile.height) / 2);
 }
 public override bool CanHitPlayer(Player target, ref int cooldownSlot)
 {
     cooldownSlot = 1;
     return(npc.Distance(FargoSoulsUtil.ClosestPointInHitbox(target, npc.Center)) < 30 * npc.scale);
 }
示例#6
0
 public override bool CanHitPlayer(Player target, ref int CooldownSlot)
 {
     CooldownSlot = 1;
     return(NPC.Distance(FargoSoulsUtil.ClosestPointInHitbox(target, NPC.Center)) < 30 * NPC.scale);
 }