예제 #1
0
 void ZapJellies()
 {
     UpdateFrame(0.15f, 10, 13);
     if (attackCounter > 20)
     {
         for (int j = 0; j < Main.npc.Length; j++)
         {
             if (Main.npc[j].type == mod.NPCType("MoonJellyMedium") && Main.npc[j].active && attackCounter % 5 == 0)
             {
                 NPC     other      = Main.npc[j];
                 Vector2 direction9 = other.Center - npc.Center;
                 int     distance   = (int)Math.Sqrt((direction9.X * direction9.X) + (direction9.Y * direction9.Y));
                 direction9.Normalize();
                 if (distance < 1000)
                 {
                     if (Main.netMode != NetmodeID.MultiplayerClient)
                     {
                         if (attackCounter < 60)
                         {
                             int proj = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)direction9.X * 15, (float)direction9.Y * 15, mod.ProjectileType("MoonPredictorTrail"), 0, 0);
                             Main.projectile[proj].timeLeft = (int)(distance / 15);
                         }
                         else
                         {
                             int proj = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)direction9.X * 30, (float)direction9.Y * 30, mod.ProjectileType("MoonLightning"), 30, 0);
                             Main.projectile[proj].timeLeft = (int)(distance / 30);
                             DustHelper.DrawElectricity(npc.Center, other.Center, 226, 0.3f, 30, default, 0.15f);
예제 #2
0
 public override void AI()
 {
     if (!initialized)
     {
         initialPos  = projectile.Center;
         initialized = true;
         throwLine   = Vector2.One.RotatedBy(Main.rand.NextFloat(6.28f));
     }
     if (projectile.timeLeft < 585 && projectile.timeLeft % 3 == 0 && projectile.timeLeft > 500)
     {
         Projectile.NewProjectile(projectile.Center, throwLine * (dist / 20), mod.ProjectileType("MoonPredictorTrail"), 0, 0);
     }
     if (projectile.timeLeft <= 500 && projectile.timeLeft > 464)
     {
         radians            += 0.0872664626f;
         projectile.velocity = (float)Math.Sin((double)radians) * (dist / 36) * throwLine;
     }
     if (projectile.timeLeft <= 500)
     {
         projectile.hostile = true;
         Vector2 distance     = initialPos - projectile.Center;
         float   electricDist = distance.Length();
         distance.Normalize();
         if (projectile.timeLeft % 4 == 0)
         {
             DustHelper.DrawElectricity(projectile.Center, initialPos, 226, 0.6f, 30, default, 0.3f);
예제 #3
0
        public override void AI()
        {
            if (Cycle == 0)              //look for point
            {
                points[0] = projectile.Center;
                projectile.extraUpdates = 10;
                float maxdist      = 400;
                var   validtargets = Main.npc.Where(x => x.CanBeChasedBy(this) && Collision.CanHit(x.Center, 0, 0, projectile.Center, 0, 0) && x.active && x != null && x.Distance(projectile.Center) < maxdist);
                if (validtargets.Any() && projectile.ai[0] > 0)                   //check if a target is in range, and if it's not the initial cycle
                {
                    NPC Finaltarget = null;
                    foreach (NPC npc in validtargets)
                    {
                        if (npc.Distance(projectile.Center) < maxdist)
                        {
                            maxdist     = npc.Distance(projectile.Center);
                            Finaltarget = npc;
                        }
                    }
                    if (Finaltarget != null)
                    {
                        projectile.ai[1] = projectile.DirectionTo(Finaltarget.Center).ToRotation();
                        SetPoint(projectile.DirectionTo(Finaltarget.Center));
                    }
                }
                else
                {
                    SetPoint(Vector2.UnitX.RotatedBy(projectile.ai[1]));
                }

                for (int i = 0; i < 2; i++)
                {
                    DustHelper.DrawElectricity(points[0], points[1], DustID.GoldCoin, 1f, 24);
                }

                projectile.Center    = points[1];
                projectile.netUpdate = true;
            }
            else if (Cycle >= (cycletimer / 3))               //pause ai
            {
                projectile.extraUpdates = 0;
                for (int i = 0; i < 3; i++)
                {
                    Dust dust = Dust.NewDustDirect(projectile.Center, 0, 0, DustID.GoldCoin);
                    dust.velocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) / 3;
                }
            }
            projectile.ai[0]++;
        }
예제 #4
0
        public override void AI()
        {
            alphaCounter += 0.04f;
            int rightValue = (int)projectile.ai[0] - 1;

            if (rightValue < (double)Main.npc.Length && rightValue != -1)
            {
                NPC     other      = Main.npc[rightValue];
                Vector2 direction9 = other.Center - projectile.Center;
                int     distance   = (int)Math.Sqrt((direction9.X * direction9.X) + (direction9.Y * direction9.Y));
                direction9.Normalize();
                if (projectile.timeLeft % 4 == 0 && distance < 1000 && other.active)
                {
                    int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)direction9.X * 30, (float)direction9.Y * 30, mod.ProjectileType("MoonLightning"), 30, 0);
                    Main.projectile[proj].timeLeft = (int)(distance / 30);
                    DustHelper.DrawElectricity(projectile.Center + (projectile.velocity * 4), other.Center + (other.velocity * 4), 226, 0.6f, 60);
                }
            }
        }
예제 #5
0
        public override void AI()
        {
            projectile.velocity *= 1.009f;
            alphaCounter        += 0.04f;
            int rightValue = (int)projectile.ai[1] - 1;

            if (rightValue < (double)Main.projectile.Length && rightValue != -1)
            {
                Projectile other      = Main.projectile[rightValue];
                Vector2    direction9 = other.Center - projectile.Center;
                int        distance   = (int)Math.Sqrt((direction9.X * direction9.X) + (direction9.Y * direction9.Y));
                direction9.Normalize();
                if (projectile.timeLeft % 4 == 0 && distance < 1000 && other.active)
                {
                    //	int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)direction9.X * 30, (float)direction9.Y * 30, mod.ProjectileType("MoonLightning"), 30, 0);
                    //	Main.projectile[proj].timeLeft = (int)(distance / 30);
                    //	Main.projectile[proj].hostile = projectile.hostile;
                    //	Main.projectile[proj].friendly = projectile.friendly;
                    DustHelper.DrawElectricity(projectile.Center + (projectile.velocity * 4), other.Center + (other.velocity * 4), 226, 0.35f, 30, default, 0.12f);
예제 #6
0
 public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
 {
     if (stuck)
     {
         ProjectileExtras.DrawChain(projectile.whoAmI, Main.player[projectile.owner].MountedCenter,
                                    "SpiritMod/Projectiles/Flail/MagnetFlail_ElectricChain", true, projectile.damage / 2);
         if (timeStuck % 3 == 0)
         {
             DustHelper.DrawElectricity(projectile.Center, Main.player[projectile.owner].MountedCenter, 226, 0.3f);
         }
     }
     else
     {
         ProjectileExtras.DrawChain(projectile.whoAmI, Main.player[projectile.owner].MountedCenter,
                                    "SpiritMod/Projectiles/Flail/MagnetFlail_Chain");
     }
     ProjectileExtras.DrawAroundOrigin(projectile.whoAmI, lightColor);
     return(false);
 }
        public override void AI()
        {
            var list = Main.projectile.Where(x1 => x1.Hitbox.Intersects(projectile.Hitbox));

            foreach (var proj in list)
            {
                if (projectile != proj && proj.friendly)
                {
                    projectile.Kill();
                }
            }
            alphaCounter += .04f;
            Lighting.AddLight(new Vector2(projectile.Center.X, projectile.Center.Y), 0.075f * 2, 0.231f * 2, 0.255f * 2);
            projectile.frameCounter++;
            projectile.spriteDirection = -projectile.direction;
            if (projectile.timeLeft % 4 == 0)
            {
                projectile.frame        = (projectile.frame + 1) % Main.projFrames[projectile.type];
                projectile.frameCounter = 0;
            }
            num1 = ModContent.NPCType <MoonjellyGiant>();
            projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f;
            float num2  = 60f;
            float x     = 0.8f * projectile.scale;
            float y     = 0.5f * projectile.scale;
            bool  flag2 = false;

            if ((double)projectile.ai[0] < (double)num2)
            {
                bool flag4  = true;
                int  index1 = (int)projectile.ai[1];
                if (Main.npc[index1].active && Main.npc[index1].type == num1)
                {
                    if (!flag2 && Main.npc[index1].oldPos[1] != Vector2.Zero)
                    {
                        projectile.position = projectile.position + Main.npc[index1].position - Main.npc[index1].oldPos[1];
                    }
                    if (projectile.timeLeft % 3 == 0)
                    {
                        DustHelper.DrawElectricity(projectile.Center + (projectile.velocity * 4), Main.npc[index1].Center + (Main.npc[index1].velocity * 4), 226, 0.35f, 30, default, 0.12f);
        public override void AI()
        {
            alphaCounter += 0.03f;
            Player player = Main.player[projectile.owner];

            if (player.HasAccessory <CimmerianScepter>())
            {
                projectile.timeLeft = 2;
            }

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

                    if (projectile.position.Y < Main.projectile[num526].position.Y)
                    {
                        projectile.velocity.Y = projectile.velocity.Y - 0.05f;
                    }
                    else
                    {
                        projectile.velocity.Y = projectile.velocity.Y + 0.05f;
                    }
                }
            }

            float num529 = 900f;
            bool  flag19 = false;

            if (projectile.ai[0] == 0f)
            {
                for (int num531 = 0; num531 < 200; num531++)
                {
                    if (Main.npc[num531].CanBeChasedBy(projectile, false))
                    {
                        float num532 = Main.npc[num531].position.X + 40 + (float)(Main.npc[num531].width / 2);
                        float num533 = Main.npc[num531].position.Y - 90 + (float)(Main.npc[num531].height / 2);
                        float num534 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num532) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num533);
                        if (num534 < num529 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num531].position, Main.npc[num531].width, Main.npc[num531].height))
                        {
                            num529 = num534;
                            flag19 = true;
                        }
                    }
                }
            }
            else
            {
                projectile.tileCollide = false;
            }

            if (!flag19)
            {
                projectile.friendly = true;
                float num535 = 8f;
                if (projectile.ai[0] == 1f)
                {
                    num535 = 12f;
                }

                Vector2 vector38 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
                float   num536   = Main.player[projectile.owner].Center.X - vector38.X;
                float   num537   = Main.player[projectile.owner].Center.Y - vector38.Y - 60f;
                float   num538   = (float)Math.Sqrt((double)(num536 * num536 + num537 * num537));
                if (num538 < 100f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
                {
                    projectile.ai[0] = 0f;
                }
                if (num538 > 2000f)
                {
                    projectile.position.X = Main.player[projectile.owner].Center.X - (projectile.width * .5f);
                    projectile.position.Y = Main.player[projectile.owner].Center.Y - (projectile.width * .5f);
                }

                if (num538 > 70f)
                {
                    num538  = num535 / num538;
                    num536 *= num538;
                    num537 *= num538;
                    projectile.velocity.X = (projectile.velocity.X * 20f + num536) * (1f / 21f);
                    projectile.velocity.Y = (projectile.velocity.Y * 20f + num537) * (1f / 21f);
                }
                else
                {
                    if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
                    {
                        projectile.velocity.X = -0.05f;
                        projectile.velocity.Y = -0.025f;
                    }
                    projectile.velocity *= 1.0035f;
                }
                projectile.friendly = false;
                projectile.rotation = projectile.velocity.X * 0.15f;

                if (Math.Abs(projectile.velocity.X) > 0.05)
                {
                    projectile.spriteDirection = -projectile.direction;
                    return;
                }
            }

            else
            {
                timer++;
                if (timer > 130 && timer < 170)
                {
                    projectile.rotation += .3f;
                }
                else
                {
                    for (int num531 = 0; num531 < 200; num531++)
                    {
                        if (Main.npc[num531].CanBeChasedBy(projectile, false))
                        {
                            projectile.rotation = projectile.DirectionTo(Main.npc[num531].Center).ToRotation() + 1.57f;
                        }
                    }
                }
                if (timer >= Main.rand.Next(180, 210))
                {
                    int   range         = 100;             //How many tiles away the projectile targets NPCs
                    float shootVelocity = 9.5f;            //magnitude of the shoot vector (speed of arrows shot)

                    //TARGET NEAREST NPC WITHIN RANGE
                    float lowestDist = float.MaxValue;
                    for (int i = 0; i < 200; ++i)
                    {
                        NPC npc = Main.npc[i];
                        //if npc is a valid target (active, not friendly, and not a critter)
                        if (npc.active && npc.CanBeChasedBy(projectile) && !npc.friendly)
                        {
                            //if npc is within 50 blocks
                            float dist = projectile.Distance(npc.Center);
                            if (dist / 16 < range)
                            {
                                //if npc is closer than closest found npc
                                if (dist < lowestDist)
                                {
                                    lowestDist = dist;

                                    //target this npc
                                    projectile.ai[1]     = npc.whoAmI;
                                    projectile.netUpdate = true;
                                }
                            }
                        }
                    }
                    NPC target = (Main.npc[(int)projectile.ai[1]] ?? new NPC());
                    timer = 0;
                    Vector2 ShootArea = new Vector2(projectile.Center.X, projectile.Center.Y - 13);
                    Vector2 direction = Vector2.Normalize(target.Center - ShootArea) * shootVelocity;
                    switch (Main.rand.Next(3))
                    {
                    case 0:                             //star attack
                        colorVer = new Color(126, 61, 255);
                        Main.PlaySound(SoundID.Item, projectile.Center, 9);
                        for (int z = 0; z < 4; z++)
                        {
                            Vector2 pos = new Vector2(projectile.Center.X + Main.rand.Next(-30, 30), projectile.Center.Y + Main.rand.Next(-30, 30));
                            DustHelper.DrawStar(pos, 272, pointAmount: 5, mainSize: 1.425f, dustDensity: 2, dustSize: .5f, pointDepthMult: 0.3f, noGravity: true);
                            int proj2 = Projectile.NewProjectile(pos.X, pos.Y, direction.X + Main.rand.Next(-2, 2), direction.Y + Main.rand.Next(-2, 2), mod.ProjectileType("CimmerianStaffStar"), projectile.damage, 0, Main.myPlayer);
                        }

                        break;

                    case 1:                             //explosion attack
                        colorVer = new Color(255, 20, 52);
                        Main.PlaySound(SoundID.DD2_GhastlyGlaiveImpactGhost, projectile.Center);
                        DustHelper.DrawCircle(projectile.Center, 130, 1, 1f, 1f, .85f, .85f);
                        int proj23 = Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, mod.ProjectileType("CimmerianRedGlyph"), projectile.damage, 0, Main.myPlayer);

                        break;

                    case 2:                             //lightning attack
                        colorVer = new Color(61, 184, 255);
                        Main.PlaySound(SoundID.Item, projectile.Center, 12);
                        for (int k = 0; k < 15; k++)
                        {
                            Dust d = Dust.NewDustPerfect(projectile.Center, 226, Vector2.One.RotatedByRandom(6.28f) * Main.rand.NextFloat(3), 0, default, Main.rand.NextFloat(.4f, .8f));
                            d.noGravity = true;
                        }
                        for (int i = 0; i < 3; i++)
                        {
                            DustHelper.DrawElectricity(projectile.Center, target.Center, 226, 0.3f);
                        }
                        target.StrikeNPC((int)(projectile.damage * 1.5f), 1f, 0, false);
                        for (int k = 0; k < 10; k++)
                        {
                            Dust d = Dust.NewDustPerfect(target.Center, 226, Vector2.One.RotatedByRandom(6.28f) * Main.rand.NextFloat(2), 0, default, Main.rand.NextFloat(.2f, .4f));