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); }
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); } } }
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); } }
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; } } }
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; */ }
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) }
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); }
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; } } }
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; }
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); }
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; } }
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); }