Beispiel #1
0
        public override void AI()
        {
            if (projectile.ai[0] < 1)
            {
                int dir = 1;
                if (Main.myPlayer == projectile.owner)
                {
                    NPC target = Main.npc[Idglib.FindClosestTarget(0, Main.MouseWorld, new Vector2(0f, 0f), true, true, true, projectile)];
                    if (target != null && Vector2.Distance(target.Center, projectile.Center) < 2000)
                    {
                        Vector2 projvel = projectile.velocity;
                        projectile.velocity = target.Center - projectile.Center;
                        projectile.velocity.Normalize(); projectile.velocity *= 8f;
                        IdgProjectile.Sync(projectile.whoAmI);
                        projectile.netUpdate = true;
                    }
                }
                dir = Math.Sign(projectile.velocity.X);
                Main.player[projectile.owner].ChangeDir(dir);
                Main.player[projectile.owner].itemRotation = (float)Math.Atan2(projectile.velocity.Y * dir, projectile.velocity.X * dir);
                //Main.player[projectile.owner].itemRotation = projectile.velocity.ToRotation() * Main.player[projectile.owner].direction;
            }
            projectile.ai[0] += 1;

            Vector2 randomcircle = new Vector2(Main.rand.Next(-8000, 8000), Main.rand.Next(-8000, 8000)); randomcircle.Normalize(); Vector2 ogcircle = randomcircle; randomcircle *= 0.1f;
            int     num655 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 206, projectile.velocity.X + randomcircle.X * 8f, projectile.velocity.Y + randomcircle.Y * 8f, 100, new Color(30, 30, 30, 20), 1f);

            Main.dust[num655].noGravity = true;
            Main.dust[num655].velocity *= 0.5f;
        }
        public override void AI()
        {
            for (int num315 = 0; num315 < 2; num315 = num315 + 1)
            {
                int num316 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, mod.DustType("NovusSparkle"), 0f, 0f, 50, Main.hslToRgb(0.4f, 0f, 0.15f), 1.7f);
                Main.dust[num316].noGravity = true;
                Dust dust3 = Main.dust[num316];
                dust3.velocity *= 0.3f;
            }

            projectile.ai[0] = projectile.ai[0] + 1;
            if (projectile.ai[0] < 2)
            {
                keepspeed = (projectile.velocity).Length();
            }
            NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];

            if (target != null)
            {
                if ((target.Center - projectile.Center).Length() < 500f)
                {
                    if (projectile.ai[0] < (250f) && projectile.ai[0] > (beginhoming))
                    {
                        projectile.velocity = projectile.velocity + (projectile.DirectionTo(target.Center) * ((float)keepspeed * homing));
                        projectile.velocity.Normalize();
                        projectile.velocity = projectile.velocity * (float)keepspeed;
                    }
                }

                if (projectile.ai[0] > 250f)
                {
                    projectile.Kill();
                }
            }
        }
Beispiel #3
0
        public override void AI()
        {
            effects(0);

            projectile.ai[0]       = projectile.ai[0] + 1;
            projectile.velocity.Y += 0.15f;
            projectile.rotation    = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;


            NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];

            if (target != null)
            {
                if (new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height).Intersects
                        (new Rectangle((int)target.position.X, (int)target.position.Y, target.width, target.height)))
                {
                    IdgNPC.AddBuffBypass(target.whoAmI, mod.BuffType("Sodden"), 60 * 45);
                    if (Main.player[projectile.owner].GetModPlayer <SGAPlayer>().MVMBoost)
                    {
                        IdgNPC.AddBuffBypass(target.whoAmI, mod.BuffType("SoddenSlow"), 60 * 45);
                    }
                    projectile.Kill();
                }
            }
        }
        public override void AI()
        {
            for (int num315 = 0; num315 < 2; num315 = num315 + 1)
            {
                int  num316 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 226, 0f, 0f, 50, Main.hslToRgb(0.4f, 0f, 0.15f), 1.7f);
                Dust dust3  = Main.dust[num316];
                dust3.velocity *= 0.3f;
                dust3.noGravity = true;
                dust3.scale     = 1.8f;
                dust3.fadeIn    = 1f + (float)Main.rand.Next(10) * 0.1f;
            }

            projectile.ai[0] = projectile.ai[0] + 1;
            if (projectile.ai[0] < 2)
            {
                keepspeed = (projectile.velocity).Length();
            }
            NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];

            if (target != null)
            {
                if ((target.Center - projectile.Center).Length() < 500f)
                {
                    if (projectile.ai[0] < (250f) && projectile.ai[0] > (beginhoming))
                    {
                        projectile.velocity = projectile.velocity + (projectile.DirectionTo(target.Center) * ((float)keepspeed * homing));
                        projectile.velocity.Normalize();
                        projectile.velocity = projectile.velocity * (float)keepspeed;
                    }
                }
            }

            projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
        }
        public override void Explode()
        {
            if (projectile.timeLeft == openclosetime && projectile.ai[0] > 0)
            {
                Player owner = Main.player[projectile.owner];
                if (owner != null && !owner.dead)
                {
                    NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];
                    if (target != null && Vector2.Distance(target.Center, projectile.Center) < 1500)
                    {
                        Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 67, 0.25f, 0.5f);

                        Vector2 gotohere = new Vector2();
                        gotohere = target.Center - projectile.Center;                        //Main.MouseScreen - projectile.Center;
                        gotohere.Normalize();

                        Vector2 perturbedSpeed = new Vector2(gotohere.X, gotohere.Y).RotatedByRandom(MathHelper.ToRadians(10)) * projectile.velocity.Length();
                        int     proj           = Projectile.NewProjectile(new Vector2(projectile.Center.X, projectile.Center.Y), new Vector2(perturbedSpeed.X, perturbedSpeed.Y), ProjectileID.BulletHighVelocity, projectile.damage, projectile.knockBack / 8f, owner.whoAmI);
                        Main.projectile[proj].timeLeft = 180;
                        //Main.projectile[proj].penetrate = 1;
                        Main.projectile[proj].GetGlobalProjectile <SGAprojectile>().onehit = true;;
                        Main.projectile[proj].netUpdate = true;
                        IdgProjectile.Sync(proj);
                    }
                }
            }
        }
Beispiel #6
0
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            //base.Shoot(player,ref position,ref speedX,ref speedY,ref type,ref damage,ref knockBack);
            SGAPlayer sgaplayer = player.GetModPlayer(mod, typeof(SGAPlayer).Name) as SGAPlayer;

            sgaplayer.ammoLeftInClip -= 1;
            if (player.altFunctionUse == 2)
            {
                damage = (int)(damage * 0.5f);
                int target2 = Idglib.FindClosestTarget(0, position, new Vector2(0, 0));
                NPC them    = Main.npc[target2];
                Vector2 where = them.Center - position;
                where.Normalize();
                Vector2 perturbedSpeed = new Vector2(where.X, where.Y) * (new Vector2(speedX, speedY).Length() * 1.25f);
                Main.PlaySound(SoundID.Item38, player.Center);
                int thisoned = Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, Main.myPlayer);
            }
            if (sgaplayer.ammoLeftInClip == 0 || forcedreload)
            {
                player.itemTime      = 40;
                player.itemAnimation = 40;
                int thisone = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, mod.ProjectileType("TheRevolverReloading"), 0, knockBack, Main.myPlayer, 0.0f, 0f);
                return(!forcedreload);
            }
            return(sgaplayer.ammoLeftInClip > 0);
        }
Beispiel #7
0
        public override void AI()
        {
            effects(0);

            projectile.ai[0]       = projectile.ai[0] + 1;
            projectile.velocity.Y += gravity;
            projectile.rotation    = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;


            if (projectile.ai[0] < (beginhoming) && !projectile.hostile)
            {
                projectile.localAI[0] = -1;
                return;
            }
            Entity target = null;

            if (projectile.localAI[0] > -1)
            {
                if (projectile.hostile)
                {
                    target = Main.player[(int)projectile.localAI[0]];
                }
                else
                {
                    target = Main.npc[(int)projectile.localAI[0]];
                }
            }

            projectile.localAI[1] += 1;
            float previousspeed = projectile.velocity.Length();

            if (projectile.localAI[0] < 0 || projectile.localAI[1] % 30 == 0 || ((!target.active || (target is NPC && ((target as NPC).dontTakeDamage || (target as NPC).life < 1))) && projectile.localAI[1] % 10 == 0))
            {
                Entity target2;
                if (projectile.hostile)
                {
                    target2 = Main.player[Idglib.FindClosestTarget(1, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];
                }
                else
                {
                    target2 = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];
                }
                projectile.localAI[0] = target2.whoAmI;
                target = target2;
            }

            if (target != null)
            {
                if ((target.Center - projectile.Center).Length() < homingdist)
                {
                    if (projectile.ai[0] < (maxhoming))
                    {
                        projectile.velocity = projectile.velocity + (projectile.DirectionTo(target.Center) * ((float)previousspeed * homing));
                        projectile.velocity.Normalize();
                        projectile.velocity = projectile.velocity * previousspeed;
                    }
                }
            }
        }
Beispiel #8
0
        public override void AI()
        {
            if (projectile.ai[0] == 0)
            {
                for (int i = 0; i < 4000; i += 1)
                {
                    if (!Collision.CanHitLine(new Vector2(projectile.Center.X, projectile.position.Y + projectile.height), 1, 1, new Vector2(projectile.Center.X, projectile.position.Y + projectile.height + 2), 1, 1))
                    {
                        break;
                    }
                    projectile.position.Y += 1;
                }
            }

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

            projectile.ai[0] += 1;
            if (projectile.ai[0] > 30)
            {
                if (projectile.ai[0] % 20 == 0)
                {
                    NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center - new Vector2(0f, 20f), new Vector2(0f, 0f), true, true, true, projectile)];
                    if (target != null && target.active && target.life > 0 && Vector2.Distance(target.Center, projectile.Center) < 300)
                    {
                        if (player.SGAPly().ConsumeElectricCharge(25, 60))
                        {
                            Vector2 there = projectile.Center - new Vector2(3f, 20f);
                            Vector2 Speed = (target.Center - there);
                            Speed.Normalize(); Speed *= 2f;
                            int prog = Projectile.NewProjectile(there.X, there.Y, Speed.X, Speed.Y, ModContent.ProjectileType <CBreakerBolt>(), projectile.damage, 1f, player.whoAmI, 0);
                            Main.projectile[prog].minion = true;
                            Main.projectile[prog].melee  = false;
                            Main.projectile[prog].usesLocalNPCImmunity = true;
                            Main.projectile[prog].localNPCHitCooldown  = -1;
                            IdgProjectile.Sync(prog);
                            Main.PlaySound(SoundID.Item93, player.Center);
                        }
                    }
                }

                for (int num315 = 0; num315 < 3; num315 = num315 + 1)
                {
                    if (Main.rand.Next(0, 15) == 0)
                    {
                        Vector2 randomcircle = new Vector2(Main.rand.Next(-8000, 8000), Main.rand.Next(-8000, 8000)); randomcircle.Normalize();
                        int     num622       = Dust.NewDust(new Vector2(projectile.Center.X, projectile.Center.Y) - new Vector2(3f, 20f) + randomcircle * 8, 0, 0, DustID.Electric, 0f, 0f, 100, default(Color), 0.75f);

                        Main.dust[num622].scale     = 1f;
                        Main.dust[num622].noGravity = true;
                        //Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
                        Main.dust[num622].velocity.X = randomcircle.RotatedBy(MathHelper.ToRadians(-90)).X;
                        Main.dust[num622].velocity.Y = randomcircle.RotatedBy(MathHelper.ToRadians(-90)).Y;
                        Main.dust[num622].alpha      = 150;
                    }
                }
            }
        }
Beispiel #9
0
        public override void AI()
        {
            projectile.velocity = new Vector2(projectile.velocity.X, projectile.velocity.Y * 0.95f);
            int q = 0;

            for (q = 0; q < 4; q++)
            {
                int dust = Dust.NewDust(projectile.position - new Vector2(100, 0), 200, 12, DustID.Smoke, 0f, projectile.velocity.Y * 0.4f, 100, colorcloud, 3f);
                Main.dust[dust].noGravity = true;
                //Main.dust[dust].velocity *= 1.8f;
                //Main.dust[dust].velocity.Y -= 0.5f;
                //Main.playerDrawDust.Add(dust);
            }
            projectile.ai[0]++;
            int    target2 = Idglib.FindClosestTarget(projectile.friendly ? 0 : 1, projectile.position, new Vector2(0, 0));
            Entity target;

            target = Main.player[target2] as Player;
            if (projectile.friendly)
            {
                target = Main.npc[target2] as NPC;
                //target=Main.player[target2];
            }

            if (target is Player)
            {
                Player targetasplayer = target as Player;
                if (targetasplayer.ownedProjectileCounts[mod.ProjectileType("SnowfallCloud")] > 0)
                {
                    projectile.Kill();
                }
            }

            if (target != null)
            {
                Vector2 dist = target.Center - projectile.position;
                if (System.Math.Abs(dist.X) < 250)
                {
                    if (projectile.ai[0] % rate == 0)
                    {
                        List <Projectile> itz = Idglib.Shattershots(projectile.Center + new Vector2(Main.rand.Next(-100, 100), 0), projectile.Center + new Vector2(Main.rand.Next(-200, 200), 500), new Vector2(0, 0), projectileid, (int)projectile.damage, 8f, 0, 1, true, 0, true, 220);
                        itz[0].friendly   = projectile.friendly;
                        itz[0].hostile    = projectile.hostile;
                        itz[0].coldDamage = true;
                        itz[0].netUpdate  = true;
                        itz[0].magic      = true;
                    }
                }
            }
        }
Beispiel #10
0
        public override void AI()
        {
            for (int num315 = 0; num315 < 2; num315 = num315 + 1)
            {
                int num316 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 92, projectile.velocity.X, projectile.velocity.Y, 50, Main.hslToRgb(0.6f, 0.9f, 1f), 1.7f);
                Main.dust[num316].noGravity = true;
                Dust dust3 = Main.dust[num316];
                dust3.velocity *= 0.3f;
                //dust3.shader = GameShaders.Armor.GetShaderFromItemId(ItemID.MidnightRainbowDye);
            }

            if (projectile.ai[0] < 1)
            {
                if (projectile.hostile)
                {
                    homing *= 1f;
                }
                projectile.ai[1] = -1;
            }

            projectile.ai[0] = projectile.ai[0] + 1;
            if (projectile.ai[0] < 2)
            {
                keepspeed = (projectile.velocity).Length();
            }
            if (gothere == null || projectile.ai[0] % 40 == 0 || projectile.ai[0] == 1)
            {
                int target3 = Idglib.FindClosestTarget(projectile.friendly ? 0 : 1, projectile.position, new Vector2(0, 0), true, true, true, projectile);

                //if (target2 > 0) {
                Entity target;
                target = Main.player[target3] as Player;
                if (projectile.friendly)
                {
                    target = Main.npc[target3] as NPC;
                    //target=Main.player[target2];
                }
                gothere = target.Center;
                projectile.netUpdate = true;
            }
            if (gothere != null && (gothere - projectile.Center).Length() < 1000f)
            {
                if (projectile.ai[0] < (Main.expertMode == true ? 150f : 50f) || projectile.friendly)
                {
                    projectile.velocity = projectile.velocity + (projectile.DirectionTo(gothere) * ((float)keepspeed * homing));
                    projectile.velocity.Normalize();
                    projectile.velocity = projectile.velocity * (float)keepspeed;
                }
            }
        }
Beispiel #11
0
        public override void AI()
        {
            for (int k = oldPos.Length - 1; k > 0; k--)
            {
                oldPos[k] = oldPos[k - 1];
            }
            oldPos[0] = projectile.Center;

            NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];

            projectile.ai[0] += 1;
            if (target != null)
            {
                Vector2 gohere = (target.Center - projectile.Center);
                float   dist   = gohere.Length();
                gohere.Normalize();
                if (dist < 1000f && projectile.ai[0] > 5 && projectile.ai[0] < 5000f)
                {
                    projectile.ai[0]    += 200f;
                    projectile.velocity += gohere / 2f;
                }
            }
            if (projectile.velocity.Length() < 7f)
            {
                projectile.velocity.Normalize();
                projectile.velocity *= 7f;
            }
            //if(Main.rand.Next(6) == 0)
            //{

            int num126 = Dust.NewDust(projectile.Center, 0, 0, 173, projectile.velocity.X, projectile.velocity.Y, 0, default(Color), 3.5f);

            Main.dust[num126].noGravity = true;
            Main.dust[num126].velocity  = projectile.Center - Main.dust[num126].position;
            Main.dust[num126].velocity *= 0.25f;

            num126 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y) + new Vector2(10 - Main.rand.Next(0, 20), 10 - Main.rand.Next(0, 20)), projectile.width, projectile.height, 173, projectile.velocity.X, projectile.velocity.Y, 0, default(Color), 2f);
            Main.dust[num126].noGravity = true;
            Main.dust[num126].velocity  = projectile.Center - Main.dust[num126].position;
            Main.dust[num126].velocity.Normalize();
            Main.dust[num126].velocity *= 1f;
            Dust dust3 = Main.dust[num126];

            dust3.velocity *= -5f;
            dust3           = Main.dust[num126];
            dust3.velocity += projectile.velocity / 2f;
            //}
        }
        public override void AI()
        {
            Lighting.AddLight(projectile.Center, Color.Aquamarine.ToVector3() * 0.5f);

            hittime = Math.Max(1f, hittime / 1.5f);
            ;
            float dist2 = 54f;

            //Vector2 positiondust = Vector2.Normalize(new Vector2(projectile.velocity.X, projectile.velocity.Y)) * 8f;
            for (float num315 = 0; num315 < MathHelper.Pi + 0.04; num315 = num315 + MathHelper.Pi)
            {
                float   angle   = (projectile.rotation + MathHelper.Pi / 5f) + num315;
                Vector2 thisloc = new Vector2((float)(Math.Cos(angle) * dist2), (float)(Math.Sin(angle) * dist2));
                Vector2 offset  = (thisloc * projectile.localAI[0]) + projectile.velocity;
                int     num316  = Dust.NewDust(new Vector2(projectile.Center.X - 1, projectile.Center.Y) + offset, 0, 0, mod.DustType("NovusSparkleBlue"), 0f, 0f, 50, Color.White, 1.5f);
                Main.dust[num316].noGravity = true;
                Main.dust[num316].velocity  = thisloc / 30f;
            }

            projectile.ai[0]       = projectile.ai[0] + 1;
            projectile.velocity.Y += 0.1f;
            if (projectile.ai[0] > 14f && !Main.player[projectile.owner].dead)
            {
                Vector2 dist     = (Main.player[projectile.owner].Center - projectile.Center);
                Vector2 distnorm = dist; distnorm.Normalize();
                projectile.velocity += distnorm * 5f;
                projectile.velocity /= 1.05f;
                //projectile.Center+=(dist*((float)(projectile.timeLeft-12)/28));
                if (dist.Length() < 80)
                {
                    projectile.Kill();
                }
            }

            NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];

            if (target != null && projectile.penetrate > 9)
            {
                if ((target.Center - projectile.Center).Length() < 500f)
                {
                    projectile.Center += (projectile.DirectionTo(target.Center) * (projectile.ai[0] > 14f ? (50f * Main.player[projectile.owner].thrownVelocity) / hittime : 12f));
                }
            }

            projectile.localAI[0] += ((hittime > 10 ? 3.0f : 0.25f) - projectile.localAI[0]) / 10f;
            projectile.localAI[0]  = MathHelper.Clamp(projectile.localAI[0], 0.5f, 1f);
            projectile.rotation   += 0.38f + (hittime / 50f);
        }
Beispiel #13
0
        public override void AI()
        {
            Lighting.AddLight(projectile.Center, Color.Aquamarine.ToVector3() * 0.5f);

            hittime = Math.Max(1f, hittime / 1.5f);
            ;
            float dist2 = 64f;

            //Vector2 positiondust = Vector2.Normalize(new Vector2(projectile.velocity.X, projectile.velocity.Y)) * 8f;
            for (double num315 = 0; num315 < Math.PI + 0.04; num315 = num315 + Math.PI)
            {
                Vector2 thisloc = new Vector2((float)(Math.Cos((projectile.rotation + Math.PI / 2.0) + num315) * dist2), (float)(Math.Sin((projectile.rotation + Math.PI / 2.0) + num315) * dist2));
                int     num316  = Dust.NewDust(new Vector2(projectile.position.X - 1, projectile.position.Y) + thisloc, projectile.width, projectile.height, mod.DustType("NovusSparkleBlue"), 0f, 0f, 50, Color.White, 1.5f);
                Main.dust[num316].noGravity = true;
                Main.dust[num316].velocity  = thisloc / 30f;
            }

            projectile.ai[0]       = projectile.ai[0] + 1;
            projectile.velocity.Y += 0.1f;
            if (projectile.ai[0] > 14f && !Main.player[projectile.owner].dead)
            {
                Vector2 dist     = (Main.player[projectile.owner].Center - projectile.Center);
                Vector2 distnorm = dist; distnorm.Normalize();
                projectile.velocity += distnorm * 5f;
                projectile.velocity /= 1.05f;
                //projectile.Center+=(dist*((float)(projectile.timeLeft-12)/28));
                if (dist.Length() < 80)
                {
                    projectile.Kill();
                }
            }

            NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];

            if (target != null && projectile.penetrate > 9)
            {
                if ((target.Center - projectile.Center).Length() < 500f)
                {
                    projectile.Center += (projectile.DirectionTo(target.Center) * (projectile.ai[0] > 14f ? (50f * Main.player[projectile.owner].thrownVelocity) / hittime : 12f));
                }
            }

            projectile.rotation += 0.38f;
        }
        public override void AI()
        {
            effects(0);

            projectile.ai[0]       = projectile.ai[0] + 1;
            projectile.velocity.Y += 0.15f;
            projectile.rotation    = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;


            NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];

            if (target != null)
            {
                if (new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height).Intersects
                        (new Rectangle((int)target.position.X, (int)target.position.Y, target.width, target.height)))
                {
                    projectile.Kill();
                }
            }
        }
        public override void AI()
        {
            if (projectile.timeLeft < 200)
            {
                projectile.aiStyle = 1;
            }
            Lighting.AddLight(projectile.position, 0.0f, 0.3f, 0.1f);
            projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;

            if (Main.rand.Next(3) == 0)
            {
                int dustIndex = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, ModContent.DustType <Dusts.MangroveDust>(), projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 200, default(Color), 0.7f);
                Main.dust[dustIndex].velocity += projectile.velocity * 0.3f;
                Main.dust[dustIndex].velocity *= 0.2f;
            }

            projectile.ai[0] = projectile.ai[0] + 1;
            if (projectile.ai[0] < 2)
            {
                keepspeed = (projectile.velocity).Length();
            }
            if (target2 == null || !target2.active)
            {
                target2 = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];
            }
            if (target2 != null)
            {
                if ((target2.Center - projectile.Center).Length() < 800f)
                {
                    if (projectile.ai[0] > (beginhoming))
                    {
                        projectile.velocity = projectile.velocity + (projectile.DirectionTo(target2.Center) * ((float)keepspeed * homing));
                        projectile.velocity.Normalize();
                        projectile.velocity = projectile.velocity * (float)keepspeed;
                    }
                }
            }
        }
        public override void AI()
        {
            base.AI();
            if (projectile.ai[0] < 1)
            {
                projectile.ai[0] = 1;
                keepspeed        = (projectile.velocity).Length();
                Main.PlaySound(SoundID.Item119, projectile.Center);
            }

            projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt();

            NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), false, true, true, projectile)];

            if (target != null)
            {
                if ((target.Center - projectile.Center).Length() < 1000f)
                {
                    projectile.velocity = projectile.velocity + (projectile.DirectionTo(target.Center) * ((float)keepspeed * homing));
                    projectile.velocity.Normalize();
                    projectile.velocity = projectile.velocity * (float)keepspeed;
                }
            }
        }
Beispiel #17
0
        public override void AI()
        {
            Player owner = Main.player[projectile.owner];

            if (owner != null && !owner.dead)
            {
                if (projectile.localAI[1] < 0)
                {
                    projectile.localAI[1] += 1;
                }


                if (projectile.localAI[1] < 1)
                {
                    NPC target = Main.npc[Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile)];
                    if (target != null && Vector2.Distance(target.Center, projectile.Center) < 72)
                    {
                        projectile.localAI[1] = 1;
                    }
                }
                else
                {
                    projectile.localAI[1] += 1;

                    int dustIndexsmoke = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 1f);
                    Main.dust[dustIndexsmoke].scale     = 0.1f + (float)Main.rand.Next(5) * 0.1f;
                    Main.dust[dustIndexsmoke].fadeIn    = 1.5f + (float)Main.rand.Next(5) * 0.1f;
                    Main.dust[dustIndexsmoke].noGravity = true;
                    Main.dust[dustIndexsmoke].position  = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default(Vector2)) * 1.1f;
                    dustIndexsmoke = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 1f);
                    Main.dust[dustIndexsmoke].scale     = 1f + (float)Main.rand.Next(5) * 0.1f;
                    Main.dust[dustIndexsmoke].noGravity = true;
                    Main.dust[dustIndexsmoke].position  = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default(Vector2)) * 1.1f;

                    if (projectile.localAI[1] > 40 && projectile.localAI[1] < 120 && projectile.localAI[1] % 25 == 0 && owner.GetModPlayer <SGAPlayer>().devempowerment[1] > 0)
                    {
                        int thisone = Projectile.NewProjectile(projectile.Center.X - 100, projectile.Center.Y - 100, Vector2.Zero.X, Vector2.Zero.Y, ModContent.ProjectileType <CreepersThrowBoom>(), projectile.damage * 2, projectile.knockBack, Main.player[projectile.owner].whoAmI, 0.0f, 0f);
                        Main.projectile[thisone].timeLeft  = 2;
                        Main.projectile[thisone].width     = 200;
                        Main.projectile[thisone].penetrate = 1;
                        Main.projectile[thisone].height    = 200;
                        Main.projectile[thisone].scale     = 0.001f;
                        Main.projectile[thisone].netUpdate = true;
                    }

                    if (projectile.localAI[1] == 121)
                    {
                        projectile.localAI[1] = -60;
                        for (int i = 0; i < 359; i += 36)
                        {
                            double  angles  = MathHelper.ToRadians(i);
                            float   randomx = 64f;                          //Main.rand.NextFloat(54f, 96f);
                            Vector2 here    = new Vector2((float)Math.Cos(angles), (float)Math.Sin(angles));

                            int thisone = Projectile.NewProjectile(projectile.Center.X + (here.X * randomx) - 100, projectile.Center.Y + (here.Y * randomx) - 100, here.X, here.Y, ModContent.ProjectileType <CreepersThrowBoom>(), projectile.damage * 1, projectile.knockBack, Main.player[projectile.owner].whoAmI, 0.0f, 0f);
                            Main.projectile[thisone].timeLeft  = 2;
                            Main.projectile[thisone].width     = 200;
                            Main.projectile[thisone].height    = 200;
                            Main.projectile[thisone].scale     = 0.001f;
                            Main.projectile[thisone].netUpdate = true;
                        }
                    }
                    if (projectile.localAI[1] == 120)
                    {
                        for (int i = 0; i < 359; i += 72)
                        {
                            double  angles  = MathHelper.ToRadians(i);
                            float   randomx = 48f;                          //Main.rand.NextFloat(54f, 96f);
                            Vector2 here    = new Vector2((float)Math.Cos(angles), (float)Math.Sin(angles));

                            int thisone = Projectile.NewProjectile(projectile.Center.X + (here.X * randomx) - 100, projectile.Center.Y + (here.Y * randomx) - 100, here.X, here.Y, ModContent.ProjectileType <CreepersThrowBoom>(), projectile.damage * 1, projectile.knockBack, Main.player[projectile.owner].whoAmI, 0.0f, 0f);
                            Main.projectile[thisone].timeLeft  = 2;
                            Main.projectile[thisone].width     = 200;
                            Main.projectile[thisone].penetrate = 1;
                            Main.projectile[thisone].height    = 200;
                            Main.projectile[thisone].scale     = 0.001f;
                            Main.projectile[thisone].netUpdate = true;
                        }
                    }
                }
            }
        }
        public override void AI()
        {
            //if (projectile.owner == null || projectile.owner < 0)
            //return;


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

            if (player.dead || !player.active)
            {
                player.ClearBuff(ModContent.BuffType <MidasMinionBuff>());
            }
            if (player.HasBuff(ModContent.BuffType <MidasMinionBuff>()))
            {
                projectile.timeLeft = 2;
            }
            Vector2 gothere = player.Center;

            projectile.localAI[0] += 1;

            int target2 = Idglib.FindClosestTarget(0, projectile.Center, new Vector2(0f, 0f), true, true, true, projectile);
            NPC them    = Main.npc[target2];
            NPC oldthem = null;

            if (player.HasMinionAttackTargetNPC)
            {
                oldthem = them;
                them    = Main.npc[player.MinionAttackTargetNPC];
                gothere = them.Center;
            }

            if (them != null && them.active)
            {
                if ((them.Center - projectile.Center).Length() < 500 && Collision.CanHitLine(new Vector2(projectile.Center.X, projectile.Center.Y), 1, 1, new Vector2(them.Center.X, them.Center.Y), 1, 1) && them.CanBeChasedBy())
                {
                    projectile.ai[0] += 1;

                    if (projectile.ai[0] % 20 == 0)
                    {
                        Main.PlaySound(18, (int)projectile.Center.X, (int)projectile.Center.Y, 0, 1f, 0.25f);
                        int thisoned = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0, 0, ProjectileID.GoldCoin, projectile.damage, projectile.knockBack, Main.player[projectile.owner].whoAmI);
                        Main.projectile[thisoned].minion   = true;
                        Main.projectile[thisoned].velocity = (them.Center - projectile.Center);
                        Main.projectile[thisoned].velocity.Normalize(); Main.projectile[thisoned].velocity *= 12f; Main.projectile[thisoned].velocity = Main.projectile[thisoned].velocity.RotateRandom(MathHelper.ToRadians(15));
                        Main.projectile[thisoned].penetrate = 1;
                        Main.projectile[thisoned].ranged    = false;
                        Main.projectile[thisoned].netUpdate = true;
                        IdgProjectile.AddOnHitBuff(thisoned, BuffID.Midas, 60 * 5);
                        IdgProjectile.Sync(thisoned);
                    }
                }

                if (oldthem != null)
                {
                    if ((oldthem.Center - projectile.Center).Length() < 500 && Collision.CanHitLine(new Vector2(projectile.Center.X, projectile.Center.Y), 1, 1, new Vector2(oldthem.Center.X, oldthem.Center.Y), 1, 1) && oldthem.CanBeChasedBy())
                    {
                        if (projectile.ai[0] % 35 == 0)
                        {
                            Main.PlaySound(18, (int)projectile.Center.X, (int)projectile.Center.Y, 0, 0.75f, -0.5f);
                            int thisoned = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0, 0, ProjectileID.SilverCoin, (int)((float)projectile.damage * 0.75f), projectile.knockBack, Main.player[projectile.owner].whoAmI);
                            Main.projectile[thisoned].minion   = true;
                            Main.projectile[thisoned].velocity = (oldthem.Center - projectile.Center);
                            Main.projectile[thisoned].velocity.Normalize(); Main.projectile[thisoned].velocity *= 10f; Main.projectile[thisoned].velocity = Main.projectile[thisoned].velocity.RotateRandom(MathHelper.ToRadians(15));
                            Main.projectile[thisoned].penetrate = 1;
                            Main.projectile[thisoned].ranged    = false;
                            Main.projectile[thisoned].netUpdate = true;
                            IdgProjectile.AddOnHitBuff(thisoned, BuffID.Midas, 60 * 2);
                            IdgProjectile.Sync(thisoned);
                        }
                    }
                }
            }

            int dust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 124);

            Main.dust[dust].scale     = 0.7f;
            Main.dust[dust].velocity  = projectile.velocity * 0.2f;
            Main.dust[dust].noGravity = true;

            float us    = 0f;
            float maxus = 0f;

            for (int i = 0; i < Main.maxProjectiles; i++)             // Loop all projectiles
            {
                Projectile currentProjectile = Main.projectile[i];
                if (currentProjectile.active &&              // Make sure the projectile is active
                    currentProjectile.owner == Main.myPlayer &&             // Make sure the projectile's owner is the client's player
                    currentProjectile.type == projectile.type)
                {                 // Make sure the projectile is of the same type as this javelin
                    if (i == projectile.whoAmI)
                    {
                        us = maxus;
                    }
                    maxus += 1f;
                }
            }
            Vector2 there = player.Center;

            double  angles = MathHelper.ToRadians((float)((us / maxus) * 360.00) - 90f);
            float   dist   = 256f;        //Main.rand.NextFloat(54f, 96f);
            Vector2 here   = new Vector2((float)Math.Cos(angles), (float)Math.Sin(angles)) * dist;

            Vector2 where = gothere + here;

            if ((where - projectile.Center).Length() > 8f)
            {
                projectile.velocity += (where - projectile.Center) * 0.005f;
                projectile.velocity *= 0.975f;
            }
            float maxspeed = Math.Min(projectile.velocity.Length(), 16);

            projectile.velocity.Normalize();
            projectile.velocity *= maxspeed;



            Lighting.AddLight(projectile.Center, Color.Yellow.ToVector3() * 0.78f);
        }