public override void AI() { //NOTE: AI[1] CONTAINS NPC.WHOAMI (so boss knows to wait until this proj is gone) Projectile.spriteDirection = Math.Sign(Projectile.velocity.X); Projectile.rotation += 0.2f * Projectile.spriteDirection; if (++Counter >= 45) { Projectile.scale += .1f; } if (EvilSqurrl) { Projectile.timeLeft++; const float maxRange = 1000f; const int maxAttacks = 20; FargoSoulsUtil.AuraDust(Projectile, maxRange, DustID.UltraBrightTorch, Color.White, true, 1f - Projectile.localAI[1] / maxAttacks); if (Counter == baseTimeleft) { if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(Terraria.Entity.InheritSource(npc is NPC ? npc : Projectile), Projectile.Center, Vector2.Zero, ModContent.ProjectileType <TimberLightningOrb>(), Projectile.damage, 0f, Main.myPlayer); } } if (Counter > baseTimeleft) { Projectile.hide = true; Projectile.position -= Projectile.velocity; Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX); Projectile.rotation += 0.1349578f * Math.Sign(Projectile.velocity.X); if (--Projectile.localAI[0] < 0) { Projectile.localAI[0] = 15; SoundEngine.PlaySound(SoundID.Item157, Projectile.Center); int lasersToAddPerAttack = 3; int modifier = (int)Projectile.localAI[1]; //scale up to halfway if (modifier >= maxAttacks / 2) //scale back down after that { modifier = maxAttacks - modifier; } int max = lasersToAddPerAttack * modifier; for (int i = 0; i < max; i++) { float ai0 = npc is NPC ? npc.whoAmI : -1; const float speed = 20f / 5f; float rotationBaseOffset = MathHelper.TwoPi / max; Vector2 vel = speed * (Projectile.rotation + rotationBaseOffset * i).ToRotationVector2(); if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(Terraria.Entity.InheritSource(npc is NPC ? npc : Projectile), Projectile.Center, vel, ModContent.ProjectileType <TimberLaser>(), Projectile.damage, 0f, Main.myPlayer, ai0); } if (npc is NPC) { float edgeRotation = Projectile.rotation + rotationBaseOffset * (i + 0.5f); Vector2 spawnPos = Projectile.Center + maxRange * edgeRotation.ToRotationVector2(); Vector2 target = Main.player[npc.target].Center + Main.player[npc.target].velocity * Main.rand.NextFloat(30f) + Main.rand.NextVector2Circular(128, 128); Vector2 edgeVel = (target - spawnPos).SafeNormalize(Vector2.UnitY); float angleDifference = MathHelper.WrapAngle(edgeVel.ToRotation() - edgeRotation); if (Math.Abs(angleDifference) > MathHelper.PiOver2) { edgeVel = (edgeRotation + MathHelper.PiOver2 * Math.Sign(angleDifference)).ToRotationVector2(); } edgeVel *= speed * 3f; if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(Terraria.Entity.InheritSource(npc), spawnPos, edgeVel, ModContent.ProjectileType <TimberLaser>(), Projectile.damage, 0f, Main.myPlayer, ai0); } } } if (++Projectile.localAI[1] >= maxAttacks) { Projectile.Kill(); } } } } }