public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            listOfPoints.Add(new Point(target.whoAmI, 1000000));
            List <NPC> closestnpcs = SGAUtils.ClosestEnemies(projectile.Center, 200, AddedWeight: listOfPoints, checkCanChase: false);

            if (target.HasBuff(BuffID.DryadsWardDebuff))
            {
                projectile.penetrate += 1;
            }

            if (closestnpcs != null && closestnpcs.Count > 0)
            {
                NPC     target2 = closestnpcs[0];
                Vector2 dist    = target2.Center - projectile.Center;

                while (dist.Length() > 24f)
                {
                    projectile.Center += Vector2.Normalize(dist) * 6f;
                    dist = target2.Center - projectile.Center;


                    int dust = Dust.NewDust(new Vector2(projectile.Center.X - 8, projectile.Center.Y - 8), 16, 16, ModContent.DustType <MangroveDust>());
                    Main.dust[dust].scale     = 1.75f;
                    Main.dust[dust].noGravity = true;
                    Main.dust[dust].velocity  = Vector2.Zero;
                }
                projectile.velocity = Vector2.Normalize(dist) * 6f;
                projectile.rotation = projectile.velocity.ToRotation() + (MathHelper.Pi / 4f);
            }
        }
Exemplo n.º 2
0
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            enemiesHit.Add(new Point(target.whoAmI, 1000000));
            if (target.SGANPCs().IrradiatedAmmount > 0 && projectile.ai[1] < 2)
            {
                projectile.ai[1]     += 1;
                projectile.penetrate += 1;
            }

            List <NPC> closestnpcs = SGAUtils.ClosestEnemies(projectile.Center, 640, projectile.Center, AddedWeight: enemiesHit, checkCanChase: false);

            target.SGANPCs().AddDamageStack((int)(damage * 1.5f), 200);

            for (float num315 = 4; num315 < 16; num315 = num315 + 1f)
            {
                Vector2 randomcircle = Vector2.Normalize(projectile.velocity) * num315;
                int     num622       = Dust.NewDust(new Vector2(projectile.Center.X, projectile.Center.Y), 0, 0, DustID.AncientLight, 0f, 0f, 100, Main.hslToRgb((projectile.whoAmI / 30f) % 1f, 1f, 0.75f), 1.5f);
                Main.dust[num622].noGravity = true;
                Main.dust[num622].velocity  = randomcircle;
                Main.dust[num622].alpha     = 100;
            }

            if (closestnpcs != null && closestnpcs.Count > 0)
            {
                float speed = projectile.velocity.Length();
                projectile.velocity = Vector2.Normalize(closestnpcs[0].Center - projectile.Center) * speed;

                SoundEffectInstance sound = Main.PlaySound(SoundID.Item7, projectile.Center);
                if (sound != null)
                {
                    sound.Pitch = -0.5f;
                }
            }
        }
Exemplo n.º 3
0
        public override void AI()
        {
            if (Main.rand.Next(0, 20) == 1)
            {
                int dust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, DustID.GoldCoin);
                Main.dust[dust].scale     = 0.20f;
                Main.dust[dust].noGravity = false;
                Main.dust[dust].velocity  = projectile.velocity * (float)(Main.rand.Next(0, 100) * 0.01f);
            }

            projectile.position -= projectile.velocity * 0.8f;

            for (int k = oldPos.Length - 1; k > 0; k--)
            {
                oldPos[k] = oldPos[k - 1];
            }
            oldPos[0] = projectile.Center;

            projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;

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

            if (projectile.ai[0] == 0 && player != null)
            {
                List <NPC> enemies = SGAUtils.ClosestEnemies(projectile.Center, 300);

                if (enemies != null && enemies.Count > 0 && player.SGAPly().ConsumeElectricCharge(30, 30))
                {
                    NPC enemy = enemies[0];
                    projectile.ai[0]    = 1;
                    projectile.velocity = Vector2.Normalize(enemy.Center - projectile.Center) * projectile.velocity.Length();
                    Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 67, 0.25f, 0.5f);
                }
            }
        }
Exemplo n.º 4
0
        public override bool PreKill(int timeLeft)
        {
            if (!onlyonce)
            {
                return(false);
            }

            int prog = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0, 0, mod.ProjectileType("BeamGunProjectileVisual"), 0, 0, Main.player[projectile.owner].whoAmI);

            Main.projectile[prog].ai[0]     = projectile.localAI[0];
            Main.projectile[prog].ai[1]     = projectile.localAI[1];
            Main.projectile[prog].netUpdate = true;

            //List<int> them = GetAllActive();

            if (lasthit != null)
            {
                projectile.Center = lasthit;
                Vector2 lastpos = projectile.Center;

                for (int i = 0; i < 5; i += 1)
                {
                    List <Point> weights = new List <Point>();
                    foreach (int id in bouncetargets)
                    {
                        weights.Add(new Point(id, 1000000));
                    }

                    List <NPC> them2 = SGAUtils.ClosestEnemies(lastpos, 300, AddedWeight: weights, checkCanChase: false) ?? null;
                    NPC        him   = null;
                    if (them2 != null && them2.Count > 0)
                    {
                        him = them2[0];
                    }

                    if (him != null)
                    {
                        int prog2 = Projectile.NewProjectile(him.Center.X, him.Center.Y, 0, 0, mod.ProjectileType("BeamGunProjectileVisual"), 0, 0, Main.player[projectile.owner].whoAmI);
                        Main.projectile[prog2].ai[0]     = lastpos.X;
                        Main.projectile[prog2].ai[1]     = lastpos.Y;
                        Main.projectile[prog2].netUpdate = true;
                        if (him.immune[projectile.owner] < 1)
                        {
                            int daxmage = Main.DamageVar((float)projectile.damage);
                            Main.player[projectile.owner].ApplyDamageToNPC(him, daxmage, projectile.knockBack, him.Center.X > lastpos.X ? 1 : -1, false);
                            //him.StrikeNPC(projectile.damage, projectile.knockBack, (him.Center.X > lastpos.X ? 1 : -1));
                            him.immune[projectile.owner] = 8;
                            if (Main.netMode != 0)
                            {
                                NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, him.whoAmI, (float)daxmage, 16f, (float)1, 0, 0, 0);
                            }
                        }
                        bouncetargets.Add(him.whoAmI);
                        lastpos = him.Center;
                    }
                }
            }
            onlyonce = false;
            return(true);
        }
Exemplo n.º 5
0
        public void Phase1Dash(Player P, ref Vector2 PWhere, ref Vector2 DrakenWhere, ref Vector2 FlyTo, ref Vector2 FlySpeed, ref Vector2 FlyFriction)
        {
            //Charging
            Vector2 Turnto = PWhere - DrakenWhere;

            if (npc.ai[0] % 80 == 30)
            {
                Turnto = SGAUtils.PredictiveAim(100f, npc.Center, P.MountedCenter, P.velocity, false) - DrakenWhere;
                Turnto.Normalize();
                npc.velocity = Turnto * 100f;
                //npc.velocity += Turnto * 70f;
                npc.rotation        = Turnto.ToRotation();
                npc.spriteDirection = (npc.velocity.X) > 0 ? 1 : -1;
                Ramming             = 30;
            }
            if (npc.ai[0] % 80 == 0)
            {
                Turnto = Turnto.RotatedBy(MathHelper.ToRadians((Main.rand.Next(30, 60) * (Main.rand.NextBool() ? 1 : 1))));
                Turnto.Normalize();
                npc.velocity        = Turnto * 80f;
                npc.velocity       += Turnto * 30f;
                npc.rotation        = Turnto.ToRotation();
                npc.spriteDirection = (npc.velocity.X) > 0 ? 1 : -1;
                Ramming             = 32;
            }
            if (npc.ai[0] % 90 > 20)
            {
                npc.rotation = npc.rotation.AngleLerp((Turnto).ToRotation(), 0.15f);
            }
            StopMoving = 80;
        }
        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
            int x = spawnInfo.spawnTileX;
            int y = spawnInfo.spawnTileY;

            return(SGAUtils.NoInvasion(spawnInfo) && spawnInfo.water && spawnInfo.player.SGAPly().DankShrineZone ? 2f : 0f);
        }
Exemplo n.º 7
0
        public override void AI()
        {
            sparkleCounter++;
            if (sparkleCounter % 15 == 0)
            {
                SGAUtils.SpelunkerGlow(npc.Center, 32);
            }

            Lighting.AddLight(npc.Center, Color.Yellow.ToVector3() * 1.00f);
        }
Exemplo n.º 8
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            if (NPC.CountNPCS(myNPC) > 0)
            {
                double  angle   = theangle + MathHelper.ToRadians(projectile.ai[0]);
                float   dist    = Math.Min(projectile.localAI[0] * 2, 96f);
                Vector2 thisloc = new Vector2((float)(Math.Cos(angle) * dist), (float)(Math.Sin(angle) * dist));

                //spriteBatch.Draw(tex, drawPos, new Rectangle(0, timing, tex.Width, (tex.Height - 1) / 10), color, projectile.velocity.X * 0.04f, drawOrigin, projectile.scale, SpriteEffects.None, 0f);
                SGAUtils.DrawFishingLine(projectile.position, Main.player[projectile.owner].Center, new Vector2(20 * Math.Sign(thisloc.X), 0), new Vector2(0, 0), 0f);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        static private void Player_AddBuff(On.Terraria.Player.orig_AddBuff orig, Player self, int buff, int time, bool quiet)
        {
            // 'orig' is a delegate that lets you call back into the original method.
            // 'self' is the 'this' parameter that would have been passed to the original method.

            SGAPlayer sgaply = self.SGAPly();

            if (sgaply.phaethonEye > 6 && Main.debuff[buff] && time > 60 && !SGAUtils.BlackListedBuffs(buff))
            {
                if (Main.rand.Next(3) == 0 && sgaply.AddCooldownStack(time))
                {
                    Projectile.NewProjectile(self.Center, Vector2.Zero, ModContent.ProjectileType <Items.Accessories.PhaethonEyeProcEffect>(), 0, 0, self.whoAmI);
                    return;
                }
            }
            orig(self, buff, time, quiet);
        }
        public override void AI()
        {
            //if (projectile.owner == null || projectile.owner < 0)
            //return;


            MakeFlies();

            int j = 0;


            List <NPC> enemiesNearby = SGAUtils.ClosestEnemies(projectile.Center, maxChaseDist);

            foreach (FakeFlyProjectile fly in flies)
            {
                NPC enemy = enemiesNearby != null ? (enemiesNearby.Count > 0 ? enemiesNearby[j % enemiesNearby.Count] : null) : null;
                fly.Update(this, enemy, j / (float)maxMinions);

                //if (enemiesNearby!=null && enemiesNearby.Count > 0)
                //enemiesNearby.RemoveAt(0);

                j += 1;
            }



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

            DoPlayerChecks(player);

            Vector2 gothere = player.Center + new Vector2(player.direction * 0, -48);

            if (player.HasMinionAttackTargetNPC)
            {
                gothere = Main.npc[player.MinionAttackTargetNPC].Center + new Vector2(0, -48);
            }

            projectile.velocity += (gothere - projectile.Center) / 50f;

            projectile.velocity /= 1.15f;

            projectile.localAI[0] += 1;

            //if (player.HasMinionAttackTargetNPC)
        }
Exemplo n.º 11
0
        public override void AI()
        {
            if (projectile.ai[0] < 1)
            {
                int dir = 1;
                if (Main.myPlayer == projectile.owner)
                {
                    List <NPC> targets = SGAUtils.ClosestEnemies(Main.player[projectile.owner].Center, 2000, Main.MouseWorld);

                    if (targets != null && targets.Count > 0)
                    {
                        NPC target = targets[0];                        // Main.npc[Idglib.FindClosestTarget(0, Main.MouseWorld, new Vector2(0f, 0f), true, true, true, projectile)];
                        if (target != null)
                        {
                            Vector2 projvel = projectile.velocity;
                            projectile.velocity = target.Center - projectile.Center;
                            projectile.velocity.Normalize(); projectile.velocity *= 8f;
                            IdgProjectile.Sync(projectile.whoAmI);
                            projectile.netUpdate = true;

                            Vector2 pos = Vector2.Normalize(target.position + new Vector2(Main.rand.Next(0, target.width), Main.rand.Next(0, target.height)) - projectile.Center);

                            Projectile.NewProjectile(projectile.Center, pos * projectile.velocity.Length() * 400, ModContent.ProjectileType <AimbotBulletEffect>(), 0, 0);
                        }
                    }
                    else
                    {
                        Vector2 pos = Vector2.Normalize(projectile.velocity);
                        Projectile.NewProjectile(projectile.Center, pos * projectile.velocity.Length() * 400, ModContent.ProjectileType <AimbotBulletEffect>(), 0, 0);
                    }
                }
                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;
             */
        }
Exemplo n.º 12
0
        public override bool CanUseItem(Player player)
        {
            if (player.statMana < 30)
            {
                return(false);
            }

            item.shoot = ModContent.ProjectileType <DrakenSummonTargetProj>();

            List <NPC> enemies = SGAUtils.ClosestEnemies(Main.MouseWorld, 64);

            List <Projectile> myproj = Main.projectile.Where(testproj => testproj.active && testproj.owner == player.whoAmI && testproj.type == ModContent.ProjectileType <DrakenSummonTargetProj>()).ToList();

            myproj = myproj.OrderBy(order => (100000 - order.localAI[1]) + (order.ai[1] >= 100000 ? 999999 : 0)).ToList();

            if (player.controlSmart)
            {
                if (myproj != null && myproj.Count > 0)
                {
                    foreach (Projectile proj in myproj)
                    {
                        proj.timeLeft = Math.Min(proj.timeLeft, 30);
                    }
                }
                item.shoot = 16;
                return(true);
            }

            if (enemies != null && enemies.Count > 0 && player.ownedProjectileCounts[ModContent.ProjectileType <DrakenSummonTargetProj>()] > 0)
            {
                NPC enemy = enemies[0];

                if (myproj != null && myproj.Count > 0 && myproj[0].ai[1] < 100000)
                {
                    myproj[0].ai[1]     = 100000 + enemy.whoAmI;
                    myproj[0].netUpdate = true;
                    item.shoot          = 16;
                    return(true);
                }
            }

            return(true);
        }
Exemplo n.º 13
0
        public override void AI()
        {
            projectile.ai[0] += 1;

            if (projectile.ai[0] == 3)
            {
                Player     owner = Main.player[projectile.owner];
                NPC        enemy = null;
                List <NPC> npcx  = SGAUtils.ClosestEnemies(projectile.Center, 320 * owner.Throwing().thrownVelocity, projectile.Center);
                if (npcx != null && npcx.Count > 0)
                {
                    enemy = npcx[0];
                }

                if (enemy != null)
                {
                    Vector2 aimvelo = Vector2.Normalize(enemy.Center - projectile.Center) * 32f;
                    int     proj    = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, aimvelo.X, aimvelo.Y, ProjectileID.MagnetSphereBolt, projectile.damage, 0, projectile.owner, 0f, 0f);
                    Main.projectile[proj].magic     = false;
                    Main.projectile[proj].netUpdate = true;
                }
            }
        }
Exemplo n.º 14
0
        public void SpinCycle(Player P, ref Vector2 PWhere, ref Vector2 DrakenWhere, ref Vector2 FlyTo, ref Vector2 FlySpeed, ref Vector2 FlyFriction)
        {
            //Draken Clone Spin Cycle
            Vector2 Turnto = PWhere - DrakenWhere;

            npc.rotation = npc.rotation.AngleLerp((Turnto).ToRotation(), 0.025f);
            Vector2 shootthere = SGAUtils.PredictiveAim(30f, npc.Center, P.MountedCenter, P.velocity, false);

            npc.Center  = npc.Center.RotatedBy(MathHelper.ToRadians(npc.ai[0] % 800 > 400 ? 5f : -5f), PWhere);
            shootthere -= DrakenWhere;
            shootthere.Normalize();
            if (StopMoving < 3)
            {
                StopMoving = 3;
            }
            if (npc.ai[0] % 3 == 0 && (npc.ai[0] % 400 > 375 || npc.ai[0] % 710 > 675))
            {
                int prog = Projectile.NewProjectile(npc.Center, shootthere * 15f, mod.ProjectileType("TrueDrakenCopy"), 80, 1f, 255, 150, npc.whoAmI);
                Main.projectile[prog].ai[0]     = 150;
                Main.projectile[prog].ai[1]     = npc.whoAmI;
                Main.projectile[prog].netUpdate = true;
                Main.PlaySound(SoundID.NPCHit, (int)npc.Center.X, (int)npc.Center.Y, 37, 0.75f, 0.5f);
            }
        }
Exemplo n.º 15
0
        public override void AI()
        {
            Player player = Main.player[base.projectile.owner];

            projectile.localAI[0] += 1;

            if (projectile.localAI[0] == 1)
            {
                if (projectile.velocity.X < 0)
                {
                    projectile.spriteDirection = -1;
                    projectile.rotation        = MathHelper.Pi;
                    projectile.ai[1]           = MathHelper.Pi;
                }

                if (projectile.localAI[0] == 1)
                {
                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/RoR2sndTurretDeploy").WithVolume(0.75f).WithPitchVariance(.15f), projectile.Center);
                }
                projectile.velocity.X = 0;
            }

            if (projectile.localAI[0] > 10)
            {
                bool  solidtiles = false;
                Point tilehere   = ((projectile.position) / 16).ToPoint();
                tilehere.Y += 2;
                for (int i = 0; i < 3; i += 1)
                {
                    Tile tile = Framing.GetTileSafely(tilehere.X + i, tilehere.Y);
                    if (WorldGen.InWorld(tilehere.X + i, tilehere.Y) && tile != null && tile.active() && (Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]))
                    {
                        solidtiles = true;
                        break;
                    }
                }

                if (solidtiles)
                {
                    projectile.velocity = new Vector2(projectile.velocity.X, 0);
                }
                else
                {
                    projectile.velocity = new Vector2(projectile.velocity.X, projectile.velocity.Y + 0.25f);
                }
            }

            if (projectile.localAI[0] < 120)
            {
                return;
            }

            float aimTo = projectile.ai[1];

            Vector2 dotRotation = projectile.rotation.ToRotationVector2();

            List <NPC> enemies = SGAUtils.ClosestEnemies(LookFrom, 640);

            if (enemies != null && enemies.Count > 0)
            {
                float   bulletspeed = 8f;
                NPC     target      = enemies[0];
                Vector2 dist;                // = target.Center - LookFrom;

                //Vector3 aimpos = SGAUtils.PredictAimingPos(LookFrom.ToVector3(), target.Center.ToVector3(), target.velocity.ToVector3(), bulletspeed, 0f);

                Vector2 offset = dotRotation.RotatedBy(MathHelper.PiOver2 * (projectile.spriteDirection)) * -6f;
                dist = SGAUtils.PredictiveAim(bulletspeed * 4f, LookFrom, target.Center, target.velocity, false) - (LookFrom + offset);

                float toRotation = dist.ToRotation();
                projectile.netUpdate = true;

                aimTo = toRotation;

                if (Vector2.Dot(dotRotation, Vector2.Normalize(dist)) > 0.98f && projectile.localAI[1] < 1)
                {
                    projectile.localAI[1] = 1;
                    Projectile proj = Projectile.NewProjectileDirect(LookFrom + offset + dotRotation * 24f, dotRotation * bulletspeed, ModContent.ProjectileType <EngineerSentryShotProj>(), projectile.damage, projectile.knockBack + 2, projectile.owner);
                    proj.rotation = proj.velocity.ToRotation();
                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/RoR2sndTurretFire").WithVolume(0.25f).WithPitchVariance(.25f), projectile.Center);
                }
            }

            projectile.rotation = projectile.rotation.AngleTowards(aimTo, 0.15f);

            if (projectile.localAI[1] > 0)            //Firing animation
            {
                projectile.localAI[1]++;
            }

            if (projectile.localAI[1] > 30)            //Firerate
            {
                projectile.localAI[1] = 0;
            }

            projectile.spriteDirection = dotRotation.X < 0 ? -1 : 1;

            if (Main.rand.Next(100) < 1)
            {
                projectile.ai[1]     = Main.rand.NextFloat(-0.75f, 0.75f) + (projectile.rotation.ToRotationVector2().X > 0 ? 0 : MathHelper.Pi);
                projectile.netUpdate = true;
            }
        }
Exemplo n.º 16
0
        public override void AI()
        {
            projectile.minion      = false;
            projectile.localAI[0] += 1;
            projectile.ai[0]      -= 1;
            float  friction = 0.98f;
            float  velosway = 60 / MathHelper.PiOver2 * (float)Math.Atan(Math.Abs(projectile.velocity.X / 5f));
            Player owner    = Main.player[projectile.owner];

            if (there == default)
            {
                there = projectile.Center;
            }

            int followPlayer = owner.ownedProjectileCounts[ModContent.ProjectileType <DrakenSummonTargetProj>()];

            if (followPlayer > 0)
            {
                if (projectile.ai[0] < 900)                //Move Order
                {
                    List <Projectile> myproj = Main.projectile.Where(testproj => testproj.active && testproj.owner == projectile.owner && testproj.type == ModContent.ProjectileType <DrakenSummonTargetProj>()).ToList();
                    myproj = myproj.OrderBy(order => order.localAI[1]).ToList();
                    if (myproj != null && myproj.Count > 0)
                    {
                        Projectile target = myproj[0];
                        projectile.damage = target.damage;

                        if (target.DistanceSQ(projectile.Center) > 200 * 200)
                        {
                            there = target.Center + Vector2.Normalize(target.Center - projectile.Center) * 640;
                        }

                        Vector2 normal = Vector2.Normalize(target.Center - projectile.Center);

                        friction = 0.98f;

                        projectile.velocity += (there - projectile.Center) / 150f;
                        projectile.velocity  = Vector2.Normalize(projectile.velocity) * Math.Min(projectile.velocity.Length() / 1f, 26f);

                        if (Vector2.Dot(normal, Vector2.Normalize(projectile.velocity)) < -0.9f && projectile.DistanceSQ(target.Center) > 32 * 32 && projectile.DistanceSQ(target.Center) < 96 * 96)
                        {
                            if (target.active)
                            {
                                target.localAI[1] += 1000;
                                target.netUpdate   = true;
                                return;
                            }
                        }

                        projectile.rotation = projectile.rotation.AngleLerp(projectile.velocity.ToRotation(), 0.1f);
                        int dir = projectile.velocity.X > 0 ? 1 : -1;
                        if (dir != projectile.spriteDirection)
                        {
                            projectile.spriteDirection = dir;
                            projectile.rotation       += MathHelper.Pi;
                        }

                        projectile.ai[0]  = 30;
                        cosmeticTrailFade = 1.2f;
                    }
                }
            }
            else
            {
                if (owner.HeldItem.type == ModContent.ItemType <DragonCommanderStaff>())
                {
                    if (projectile.ai[0] < 1)
                    {
                        there = owner.Center + new Vector2(-projectile.spriteDirection * 48, -72);
                        if (projectile.velocity.Length() > 3f || projectile.velocity.Length() < 0.25f)
                        {
                            int dir = projectile.velocity.Length() > 3f ? (projectile.rotation.ToRotationVector2().X > 0 ? 1 : -1) : owner.direction;
                            if (dir != projectile.spriteDirection)
                            {
                                projectile.spriteDirection = dir;
                                projectile.rotation       += MathHelper.Pi;
                            }
                        }
                        projectile.rotation = projectile.rotation.AngleLerp(projectile.velocity.Length() > 3f ? projectile.velocity.ToRotation() : projectile.spriteDirection < 0 ? MathHelper.Pi : 0, 0.01f);
                        projectile.velocity = (there - projectile.Center) / 40f;
                    }

                    if (projectile.ai[0] < 1 && owner.HeldItem.type == ModContent.ItemType <DragonCommanderStaff>())
                    {
                        projectile.ai[0]  = 0;
                        projectile.damage = owner.HeldItem.damage;
                        owner.AddBuff(ModContent.BuffType <DrakenDefenseBuff>(), 3);
                    }
                }
            }

            if (projectile.ai[0] >= 0)
            {
                projectile.timeLeft = 300;
            }

            if (projectile.ai[0] < -5 && projectile.ai[0] > -240)
            {
                if (projectile.ai[0] % 15 == 0)
                {
                    List <NPC> enemies = SGAUtils.ClosestEnemies(projectile.Center, 200, checkCanChase: false);
                    if (enemies != null && enemies.Count > 0)
                    {
                        foreach (NPC enemy in enemies)
                        {
                            float damazz = (Main.DamageVar((float)projectile.damage * 2) * (1f - (enemy.DistanceSQ(projectile.Center) / (200 * 200))));
                            enemy.StrikeNPC((int)damazz, 0f, 0, false, true, true);
                            owner.addDPS((int)damazz);
                            if (Main.netMode != 0)
                            {
                                NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, enemy.whoAmI, damazz, 16f, (float)1, 0, 0, 0);
                            }
                        }
                    }
                }
            }


            projectile.velocity *= friction;
            cosmeticTrailFade   -= 0.04f;

            projectile.Opacity = alphaStrength;
        }
Exemplo n.º 17
0
        public override bool PreDrawExtras(SpriteBatch spriteBatch)      //this draws the fishing line correctly
        {
            if (projectile.bobber && Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].holdStyle > 0)
            {
                Lighting.AddLight(projectile.Center, 0.13f, 0.86f, 0.59f);  //this defines the projectile/bobber light color
                Player player = Main.player[projectile.owner];
                float  pPosX  = player.MountedCenter.X;
                float  pPosY  = player.MountedCenter.Y;
                pPosY += Main.player[projectile.owner].gfxOffY;

                SGAUtils.DrawFishingLine(new Vector2(pPosX, pPosY), projectile.Center, projectile.velocity, projectile.Center + new Vector2(0, 32), projectile.localAI[0]);

                /*float pPosX = player.MountedCenter.X;
                 * float pPosY = player.MountedCenter.Y;
                 * pPosY += Main.player[projectile.owner].gfxOffY;
                 * int type = Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].type;
                 * float gravDir = Main.player[projectile.owner].gravDir;
                 *
                 * if (type == mod.ItemType("LunarRod")) //add your Fishing Pole name here
                 * {
                 *  pPosX += (float)(50 * Main.player[projectile.owner].direction);
                 *  if (Main.player[projectile.owner].direction < 0)
                 *  {
                 *      pPosX -= 13f;
                 *  }
                 *  pPosY -= 30f * gravDir;
                 * }
                 *
                 * if (gravDir == -1f)
                 * {
                 *  pPosY -= 12f;
                 * }
                 * Vector2 value = new Vector2(pPosX, pPosY);
                 * value = Main.player[projectile.owner].RotatedRelativePoint(value + new Vector2(8f), true) - new Vector2(8f);
                 * float projPosX = projectile.position.X + (float)projectile.width * 0.5f - value.X;
                 * float projPosY = projectile.position.Y + (float)projectile.height * 0.5f - value.Y;
                 * Math.Sqrt((double)(projPosX * projPosX + projPosY * projPosY));
                 * float rotation2 = (float)Math.Atan2((double)projPosY, (double)projPosX) - 1.57f;
                 * bool flag2 = true;
                 * if (projPosX == 0f && projPosY == 0f)
                 * {
                 *  flag2 = false;
                 * }
                 * else
                 * {
                 *  float projPosXY = (float)Math.Sqrt((double)(projPosX * projPosX + projPosY * projPosY));
                 *  projPosXY = 12f / projPosXY;
                 *  projPosX *= projPosXY;
                 *  projPosY *= projPosXY;
                 *  value.X -= projPosX;
                 *  value.Y -= projPosY;
                 *  projPosX = projectile.position.X + (float)projectile.width * 0.5f - value.X;
                 *  projPosY = projectile.position.Y + (float)projectile.height * 0.5f - value.Y;
                 * }
                 * while (flag2)
                 * {
                 *  float num = 12f;
                 *  float num2 = (float)Math.Sqrt((double)(projPosX * projPosX + projPosY * projPosY));
                 *  float num3 = num2;
                 *  if (float.IsNaN(num2) || float.IsNaN(num3))
                 *  {
                 *      flag2 = false;
                 *  }
                 *  else
                 *  {
                 *      if (num2 < 20f)
                 *      {
                 *          num = num2 - 8f;
                 *          flag2 = false;
                 *      }
                 *      num2 = 12f / num2;
                 *      projPosX *= num2;
                 *      projPosY *= num2;
                 *      value.X += projPosX;
                 *      value.Y += projPosY;
                 *      projPosX = projectile.position.X + (float)projectile.width * 0.5f - value.X;
                 *      projPosY = projectile.position.Y + (float)projectile.height * 0.1f - value.Y;
                 *      if (num3 > 12f)
                 *      {
                 *          float num4 = 0.3f;
                 *          float num5 = Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y);
                 *          if (num5 > 16f)
                 *          {
                 *              num5 = 16f;
                 *          }
                 *          num5 = 1f - num5 / 16f;
                 *          num4 *= num5;
                 *          num5 = num3 / 80f;
                 *          if (num5 > 1f)
                 *          {
                 *              num5 = 1f;
                 *          }
                 *          num4 *= num5;
                 *          if (num4 < 0f)
                 *          {
                 *              num4 = 0f;
                 *          }
                 *          num5 = 1f - projectile.localAI[0] / 100f;
                 *          num4 *= num5;
                 *          if (projPosY > 0f)
                 *          {
                 *              projPosY *= 1f + num4;
                 *              projPosX *= 1f - num4;
                 *          }
                 *          else
                 *          {
                 *              num5 = Math.Abs(projectile.velocity.X) / 3f;
                 *              if (num5 > 1f)
                 *              {
                 *                  num5 = 1f;
                 *              }
                 *              num5 -= 0.5f;
                 *              num4 *= num5;
                 *              if (num4 > 0f)
                 *              {
                 *                  num4 *= 2f;
                 *              }
                 *              projPosY *= 1f + num4;
                 *              projPosX *= 1f - num4;
                 *          }
                 *      }
                 *      rotation2 = (float)Math.Atan2((double)projPosY, (double)projPosX) - 1.57f;
                 *      Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)value.X / 16, (int)(value.Y / 16f), new Microsoft.Xna.Framework.Color(34, 221, 151, 100));
                 *
                 *      Main.spriteBatch.Draw(Main.fishingLineTexture, new Vector2(value.X - Main.screenPosition.X + (float)Main.fishingLineTexture.Width * 0.5f, value.Y - Main.screenPosition.Y + (float)Main.fishingLineTexture.Height * 0.5f), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, 0, Main.fishingLineTexture.Width, (int)num)), color2, rotation2, new Vector2((float)Main.fishingLineTexture.Width * 0.5f, 0f), 1f, SpriteEffects.None, 0f);
                 *  }
                 * }*/
            }
            return(false);
        }
Exemplo n.º 18
0
 public override float SpawnChance(NPCSpawnInfo spawnInfo)
 {
     return(spawnInfo.water && SGAUtils.NoInvasion(spawnInfo) && spawnInfo.player.SGAPly().DankShrineZone ? 0.75f : 0f);
 }
        public void DoApoco(NPC npc, Projectile projectile, Player player, Item item, ref int damage, ref float knockback, ref bool crit, int bitBoldedEffects = 7, bool always = false)
        {
            bool effectSound     = (bitBoldedEffects & (1 << 1 - 1)) != 0;
            bool effectText      = (bitBoldedEffects & (1 << 2 - 1)) != 0;
            bool effectShockwave = (bitBoldedEffects & (1 << 3 - 1)) != 0;

            SGAPlayer moddedplayer = player.GetModPlayer <SGAPlayer>();
            int       chance       = -1;

            if (projectile != null)
            {
                if (projectile.melee)
                {
                    chance = 0;
                }
                if (projectile.ranged)
                {
                    chance = 1;
                }
                if (projectile.magic)
                {
                    chance = 2;
                }
                if (projectile.thrown || projectile.Throwing().thrown)
                {
                    chance = 3;
                }
            }
            if (item != null)
            {
                if (item.melee)
                {
                    chance = 0;
                }
                if (item.ranged)
                {
                    chance = 1;
                }
                if (item.magic)
                {
                    chance = 2;
                }
                if (item.thrown || item.Throwing().thrown)
                {
                    chance = 3;
                }
            }
            if (npc != null && (always || chance > -1))
            {
                double chanceboost = 0;
                if (projectile != null)
                {
                    chanceboost += projectile.GetGlobalProjectile <SGAprojectile>().extraApocoChance;
                }

                if (always || (crit && Main.rand.Next(0, 100) < (moddedplayer.apocalypticalChance[chance] + chanceboost)))
                {
                    if (moddedplayer.HoE && projectile != null)
                    {
                        float ammount = damage;
                        if (moddedplayer.lifestealentropy > 0)
                        {
                            projectile.vampireHeal((int)((ammount * moddedplayer.apocalypticalStrength)), npc.Center);
                            moddedplayer.lifestealentropy -= ammount;
                        }
                    }

                    if (moddedplayer.ninjaSash > 2)
                    {
                        for (int i = 0; i < Main.maxProjectiles; i += 1)
                        {
                            Projectile proj = Main.projectile[i];
                            if (proj.active && proj.owner == player.whoAmI)
                            {
                                if (proj.Throwing().thrown || proj.thrown)
                                {
                                    proj.SGAProj().Embue(projectile);
                                }
                            }
                        }
                    }

                    if (moddedplayer.SybariteGem)
                    {
                        float mul     = moddedplayer.apocalypticalStrength * (((float)damage * 3f) / (float)npc.lifeMax);
                        int   ammount = (int)((float)npc.value * mul);


                        Vector2 pos = new Vector2((int)npc.position.X, (int)npc.position.Y);
                        pos += new Vector2(Main.rand.Next(npc.width), Main.rand.Next(npc.height));
                        SGAUtils.SpawnCoins(pos, ammount, 10f + Math.Min(3f * mul, 20f));
                    }

                    if (moddedplayer.dualityshades)
                    {
                        int ammo = 0;
                        for (int i = 0; i < 4; i += 1)
                        {
                            if (moddedplayer.ammoinboxes[i] > 0)
                            {
                                int  ammox = moddedplayer.ammoinboxes[i];
                                Item itemx = new Item();
                                itemx.SetDefaults(ammox);
                                if (itemx.ammo == AmmoID.Bullet)
                                {
                                    ammo = ammox;
                                    break;
                                }
                            }
                        }
                        if (ammo > 0)
                        {
                            Item itemy = new Item();
                            itemy.SetDefaults(ammo);
                            int shootype = itemy.shoot;

                            for (int i = 128; i < 260; i += 128)
                            {
                                Vector2 anglez = new Vector2(Main.rand.Next(-8000, 8000), Main.rand.Next(-8000, 8000));
                                anglez.Normalize();

                                Main.PlaySound(SoundID.Item, (int)((npc.Center.X) + (anglez.X * i)), (int)((npc.Center.Y) + (anglez.Y * i)), 25, 0.5f, Main.rand.NextFloat(-0.9f, -0.25f));

                                int thisoned = Projectile.NewProjectile(npc.Center + (anglez * i), anglez * -16f, shootype, (int)(damage * 1.50f * moddedplayer.apocalypticalStrength), 0f, Main.myPlayer);
                                Main.projectile[thisoned].ranged = false;


                                for (float gg = 4f; gg > 0.25f; gg -= 0.15f)
                                {
                                    int  dustIndex = Dust.NewDust(npc.Center + new Vector2(-8, -8) + (anglez * i), 16, 16, DustID.AncientLight, -anglez.X * gg, -anglez.Y * gg, 150, Color.Purple, 3f);
                                    Dust dust      = Main.dust[dustIndex];
                                    dust.noGravity = true;
                                }

                                player.ConsumeItemRespectInfiniteAmmoTypes(ammo);
                            }
                        }
                    }

                    if (moddedplayer.RadSuit)
                    {
                        //IrradiatedAmmount = Math.Max(IrradiatedAmmount, 25);

                        IrradiatedExplosion(npc, (int)(damage * 1f * moddedplayer.apocalypticalStrength));

                        SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_DarkMageHealImpact, (int)npc.Center.X, (int)npc.Center.Y);
                        if (sound != null)
                        {
                            sound.Pitch += 0.525f;
                        }

                        int proj;

                        if (projectile != null)
                        {
                            proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType <RadioactivePool>(), (int)(damage * 0.5f * moddedplayer.apocalypticalStrength), projectile.knockBack, projectile.owner);
                        }
                        else
                        {
                            proj = Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <RadioactivePool>(), (int)(damage * 0.5f * moddedplayer.apocalypticalStrength), knockback, player.whoAmI);
                        }

                        Main.projectile[proj].width    += 80;
                        Main.projectile[proj].height   += 80;
                        Main.projectile[proj].timeLeft += (int)(30 * moddedplayer.apocalypticalStrength);
                        Main.projectile[proj].Center   -= new Vector2(40, 40);
                        Main.projectile[proj].netUpdate = true;
                    }

                    if (moddedplayer.CalamityRune)
                    {
                        Main.PlaySound(SoundID.Item45, npc.Center);
                        int boom = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, mod.ProjectileType("BoulderBlast"), (int)((damage * 2) * moddedplayer.apocalypticalStrength), knockback * 2f, player.whoAmI, 0f, 0f);
                        Main.projectile[boom].usesLocalNPCImmunity = true;
                        Main.projectile[boom].localNPCHitCooldown  = -1;
                        Main.projectile[boom].netUpdate            = true;
                        IdgProjectile.AddOnHitBuff(boom, BuffID.Daybreak, (int)(60f * moddedplayer.apocalypticalStrength));
                        IdgProjectile.AddOnHitBuff(boom, mod.BuffType("EverlastingSuffering"), (int)(400f * moddedplayer.apocalypticalStrength));
                    }

                    damage = (int)(damage * (3f + (moddedplayer.apocalypticalStrength - 1f)));

                    if (moddedplayer.magatsuSet && npc.HasBuff(ModContent.BuffType <Watched>()))
                    {
                        Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <Items.Armors.Magatsu.ExplosionDarkSectorEye>(), 0, 0);

                        Point location;

                        if (projectile != null)
                        {
                            location = new Point((int)projectile.Center.X, (int)projectile.Center.Y);
                        }
                        else
                        {
                            location = new Point((int)npc.Center.X, (int)npc.Center.Y);
                        }

                        SoundEffectInstance sound = Main.PlaySound(SoundID.DD2_WyvernScream, (int)location.X, (int)location.Y);
                        if (sound != null)
                        {
                            sound.Pitch = 0.925f;
                        }

                        foreach (NPC enemy in Main.npc.Where(testby => testby.active && !testby.dontTakeDamage && !testby.friendly && testby != npc && (testby.Center - npc.Center).LengthSquared() < 400 * 400))
                        {
                            int damazz = Main.DamageVar(damage);
                            enemy.StrikeNPC(damazz, 16, -enemy.spriteDirection, true);

                            if (Main.netMode != 0)
                            {
                                NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, damazz, 16f, (float)1, 0, 0, 0);
                            }
                        }
                    }

                    if (effectText)
                    {
                        CombatText.NewText(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), Color.DarkRed, "Apocalyptical!", true, false);
                    }
                    if (SGAConfigClient.Instance.EpicApocalypticals)
                    {
                        if (effectShockwave)
                        {
                            RippleBoom.MakeShockwave(npc.Center, 8f, 1f, 10f, 60, 1f);
                            if (SGAmod.ScreenShake < 32)
                            {
                                SGAmod.AddScreenShake(24f, 1200, player.Center);
                            }
                        }
                        if (effectSound)
                        {
                            Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/crit_hit").WithVolume(.7f).WithPitchVariance(.25f), npc.Center);
                        }
                    }
                }
            }
        }
Exemplo n.º 20
0
        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
            int rand = Main.rand.Next(1, 95);

            return(Main.hardMode && rand == 45 && SGAUtils.NoInvasion(spawnInfo) && spawnInfo.spawnTileType == mod.TileType("MoistStone") && spawnInfo.player.SGAPly().DankShrineZone ? 0.5f : 0f);
        }
Exemplo n.º 21
0
        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
            int spawn = Main.rand.Next(100);

            return(Main.hardMode && spawnInfo.spawnTileY < Main.rockLayer && (SGAUtils.NoInvasion(spawnInfo) && spawn == 24 || (spawnInfo.spawnTileType == mod.TileType("MoistStone") && spawn < 4)) ? 1f : 0f);
        }
Exemplo n.º 22
0
 public override float SpawnChance(NPCSpawnInfo spawnInfo)
 {
     return(SGAUtils.NoInvasion(spawnInfo) && spawnInfo.spawnTileType == mod.TileType("MoistStone") && spawnInfo.player.SGAPly().DankShrineZone ? 0.75f : 0f);
 }
        public override void AI()
        {
            //if (projectile.owner == null || projectile.owner < 0)
            //return;

            projectile.ai[0]++;
            projectile.localAI[0]++;
            Player player = Main.player[projectile.owner];

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



            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;
                }
            }

            float percent = us / maxus;
            int   ptimer  = player.SGAPly().timer;

            double  angles = (percent * MathHelper.TwoPi) + ((ptimer * player.direction) / 30f);
            float   dist   = 64f;
            Vector2 here   = Vector2.One.RotatedBy(angles) * dist;

            Vector2 where = gothere + here;

            NPC enemy = null;

            List <NPC> enemies = SGAUtils.ClosestEnemies(projectile.Center, 1200, player.Center);

            if (enemies != null && enemies.Count > 0)
            {
                enemy = enemies[0];
            }

            if (player.HasMinionAttackTargetNPC)
            {
                enemy = Main.npc[player.MinionAttackTargetNPC];
            }

            if (enemy != null)
            {
                where = enemy.Center + Vector2.Normalize(projectile.Center - enemy.Center).RotatedBy((-MathHelper.PiOver2 + (angles * MathHelper.Pi)) / 1.5f) * (dist * 2);

                Vector2 generalDist = enemy.Center - projectile.Center;

                projectile.spriteDirection = generalDist.X > 0 ? 1 : -1;

                if ((int)projectile.ai[0] % 80 == 0 && generalDist.Length() < dist + 360)
                {
                    for (float xx = 0f; xx < 6f; xx += 1f)
                    {
                        Vector2 aiming = Vector2.Normalize(generalDist) * 32f + new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-3, 3f));

                        Vector2 distxxx = SGAUtils.PredictiveAim(aiming.Length(), projectile.Center, enemy.Center, enemy.velocity, false) - (projectile.Center);

                        int proj2 = Projectile.NewProjectile(projectile.Center, (Vector2.Normalize(distxxx) * aiming.Length()) + new Vector2(Main.rand.NextFloat(-8f, 8f), Main.rand.NextFloat(-8, 8f)), ProjectileID.IceBolt, (int)((float)projectile.damage * 1f), 0f, projectile.owner);
                        Main.projectile[proj2].friendly  = true;
                        Main.projectile[proj2].minion    = true;
                        Main.projectile[proj2].timeLeft  = 30;
                        Main.projectile[proj2].melee     = false;
                        Main.projectile[proj2].hostile   = false;
                        Main.projectile[proj2].netUpdate = true;
                    }
                }
            }
            else
            {
                projectile.spriteDirection = projectile.velocity.X > 0 ? 1 : -1;
            }

            if ((int)(ptimer + percent * 30) % 30 == 0)
            {
                List <Projectile> allfriendlyprojs = Main.projectile.Where(testby => testby.active && !testby.coldDamage && testby.damage > 0 && testby.owner == projectile.owner && projectile.type != testby.type && (testby.Center - projectile.Center).LengthSquared() < 640000).OrderBy(testby => (testby.Center - projectile.Center).LengthSquared()).ToList();

                if (allfriendlyprojs.Count > 0)
                {
                    Projectile coldenproj = allfriendlyprojs[0];
                    coldenproj.coldDamage = true;
                    if (!coldenproj.hostile)
                    {
                        coldenproj.damage = (int)(coldenproj.damage * (1f + (player.minionDamage - 1f) * 0.25f));
                    }
                    coldenproj.netUpdate = true;

                    Vector2 generalDist = coldenproj.Center - projectile.Center;

                    for (int i = 0; i < 60; i += 1)
                    {
                        int dustx = Dust.NewDust(new Vector2(coldenproj.position.X, coldenproj.position.Y), coldenproj.width, coldenproj.height, 80);
                        Main.dust[dustx].scale     = 1.25f;
                        Main.dust[dustx].velocity  = Main.rand.NextVector2Circular(4f, 4f) + Vector2.Normalize(generalDist) * 1f;
                        Main.dust[dustx].noGravity = true;
                    }

                    Main.PlaySound(SoundID.Item, (int)coldenproj.Center.X, (int)coldenproj.Center.Y, 30, 1f, -0.5f);
                }
            }


            //				Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 30, 1f, -0.5f);


            if ((where - projectile.Center).Length() > 8f)
            {
                projectile.velocity += Vector2.Normalize((where - projectile.Center)) * 0.01f;
                projectile.velocity += (where - projectile.Center) * 0.0025f;
                projectile.velocity *= 0.975f;
            }
            float maxspeed = Math.Min(projectile.velocity.Length(), 32);

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

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

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

            Lighting.AddLight(projectile.Center, Color.Aqua.ToVector3() * 0.78f);
        }
Exemplo n.º 24
0
        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
            int spawn = Main.rand.Next(1, 3);

            return(spawn == 2 && SGAUtils.NoInvasion(spawnInfo) && spawnInfo.spawnTileType == mod.TileType("MoistStone") && spawnInfo.player.SGAPly().DankShrineZone ? 0.50f : 0f);
        }
Exemplo n.º 25
0
        public override void AI()
        {
            //if (projectile.owner == null || projectile.owner < 0)
            //return;

            Player player = ThePlayer;

            int attackrate = 40;


            if (player.dead || !player.active)
            {
                player.ClearBuff(ModContent.BuffType <AutoclickerMinionBuff>());
            }
            if (player.HasBuff(ModContent.BuffType <AutoclickerMinionBuff>()))
            {
                projectile.timeLeft = 2;
            }
            Vector2 there = player.Center;
            float   dist  = projectile.ai[1] < 1 ? 64 : 8f;

            projectile.localAI[0] += 1;
            projectile.ai[0]      += 1;
            projectile.ai[1]      -= 1;
            clickDelay            -= 1;

            float id    = 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)
                    {
                        id = maxus;
                    }
                    maxus += 1f;
                }
            }
            projectile.localAI[1] = id / maxus;

            NPC    them    = null;
            Entity focusOn = player;

            if (player.HasMinionAttackTargetNPC)
            {
                them    = Main.npc[player.MinionAttackTargetNPC];
                there   = them.Center;
                focusOn = them;
            }
            else
            {
                List <NPC> enemies = SGAUtils.ClosestEnemies(projectile.Center, 2200, projectile.ai[1] > 0 ? projectile.Center : player.Center, checkWalls: false);
                if (enemies != null && enemies.Count > 0)
                {
                    enemies = enemies.OrderBy(testby => testby.life).ToList();
                    them    = enemies[(int)id % enemies.Count];
                    there   = them.Center;
                    focusOn = them;
                }
            }

            float   angles = ((id / (float)maxus) * MathHelper.TwoPi) - player.SGAPly().timer / 150f;
            Vector2 here   = new Vector2((float)Math.Cos(angles), (float)Math.Sin(angles)) * dist;

            Vector2 where = there + here;
            Vector2 todist     = (where - projectile.Center);        // +(focusOn != null ? focusOn.velocity : Vector2.Zero);
            Vector2 todistreal = (there - projectile.Center);

            float lookat = todist.ToRotation();

            if (them == null)
            {
                lookat = (focusOn.Center - projectile.Center).ToRotation();
            }

            if (todistreal.Length() > 0.01f)
            {
                if (todistreal.Length() > 600f)
                {
                    projectile.velocity += Vector2.Normalize(todist) * MathHelper.Clamp(todist.Length() / 6f, 0f, 64f);
                    projectile.velocity *= 0.940f;
                }
                else
                {
                    projectile.Center   += todist * (projectile.ai[1] > -(attackrate / (ClickerBoost ? 10f : 5f)) ? 0.25f : 0.98f);
                    projectile.velocity *= 0.820f;
                }
            }
            if (projectile.velocity.Length() > 1f)
            {
                float maxspeed = Math.Min(projectile.velocity.Length(), 16 + (todist.Length() / 4f));
                projectile.velocity.Normalize();
                projectile.velocity *= maxspeed;
            }

            if (todistreal.Length() > 160f && (projectile.ai[1] < 0 || them == null))
            {
                if (them != null)
                {
                    lookat = 0;
                }
                projectile.rotation = projectile.rotation.AngleLerp(lookat, 0.05f);
            }
            else
            {
                lookat = (focusOn.Center - projectile.Center).ToRotation();
                projectile.rotation = projectile.rotation.AngleLerp(lookat, 0.15f);
                if (them != null)
                {
                    if (player.SGAPly().timer % (int)(attackrate * (ClickerBoost ? 0.5f : 1f)) == (int)(((id * (attackrate / maxus))) * (ClickerBoost ? 0.5f : 1f)))
                    {
                        DoClick();
                    }
                    if (clickDelay == 0)
                    {
                        Main.PlaySound(SoundID.MenuTick, (int)projectile.Center.X, (int)projectile.Center.Y, 0);

                        if (!them.IsDummy() && Main.rand.Next(500) < player.maxTurrets && player.HeldItem.type == ModContent.ItemType <Autoclicker>())
                        {
                            bool cookieNearby = false;
                            int  range        = 900 + (ClickerBoost ? 600 : 0);
                            foreach (Item item in Main.item.Where(testby => testby.active && testby.type == ModContent.ItemType <ClickerCookie>() && (testby.Center - them.Center).LengthSquared() < (range * range)))
                            {
                                cookieNearby = true;
                            }
                            if (!cookieNearby)
                            {
                                Item.NewItem(them.Center, ModContent.ItemType <ClickerCookie>(), prefixGiven: PrefixID.Menacing, noGrabDelay: true);
                            }
                        }
                        int damage = (int)(projectile.damage * (ClickerBoost ? 0.60f : 1f));
                        //them.SGANPCs().AddDamageStack(damage,60*5);
                        Projectile.NewProjectile(them.Center, projectile.rotation.ToRotationVector2(), ModContent.ProjectileType <AutoclickerClickProj>(), damage, projectile.knockBack, projectile.owner);


                        /*int damazz = (Main.DamageVar((float)projectile.damage));
                         * them.StrikeNPC(damazz, projectile.knockBack, them.direction, false, false);
                         * player.addDPS(damazz);
                         * if (Main.netMode != NetmodeID.SinglePlayer)
                         * {
                         *      NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, them.whoAmI, damazz, 16f, (float)1, 0, 0, 0);
                         * }*/
                    }
                }
            }

            projectile.velocity *= 0.96f;

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