public override void AI() { Lighting.AddLight(projectile.Center, 0f, .7f, 0f); ActiveSound activeSound = Main.GetActiveSound(SlotId.FromFloat(projectile.localAI[0])); if (activeSound != null) { if (activeSound.Volume == 0f) { activeSound.Stop(); projectile.localAI[0] = SlotId.Invalid.ToFloat(); } activeSound.Volume = Math.Max(0f, activeSound.Volume - 0.05f); } else { projectile.localAI[0] = SlotId.Invalid.ToFloat(); } if (projectile.ai[1] == 1f) { if (projectile.alpha < 255) { projectile.alpha += 51; } if (projectile.alpha >= 255) { projectile.alpha = 255; projectile.Kill(); return; } } else { if (projectile.alpha > 0) { projectile.alpha -= 50; } if (projectile.alpha < 0) { projectile.alpha = 0; } } float num726 = 30f; float num727 = num726 * 4f; projectile.ai[0] += 1f; if (projectile.ai[0] > num727) { projectile.ai[0] = 0f; } Vector2 vector62 = -Vector2.UnitY.RotatedBy(6.28318548f * projectile.ai[0] / num726, default); float val = 0.75f + vector62.Y * 0.25f; float val2 = 0.8f - vector62.Y * 0.2f; float num728 = Math.Max(val, val2); projectile.position += new Vector2(projectile.width, projectile.height) / 2f; projectile.width = (projectile.height = (int)(80f * num728)); projectile.position -= new Vector2(projectile.width, projectile.height) / 2f; projectile.frameCounter++; if (projectile.frameCounter >= 3) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame >= 4) { projectile.frame = 0; } } for (int num729 = 0; num729 < 1; num729++) { float num730 = 55f * num728; float num731 = 11f * num728; float num732 = 0.5f; int num733 = Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType <Dusts.StarDust>(), 0f, 0f, 100, default, 0.5f);
public override void AI() { npc.rotation = npc.velocity.ToRotation(); float num = 0.4f; float num2 = 10f; float scaleFactor = 200f; float num3 = 750f; float num4 = 30f; float num5 = 30f; float scaleFactor2 = 0.95f; int num6 = 50; float scaleFactor3 = 14f; float num7 = 30f; float num8 = 100f; float num9 = 20f; float num10 = 0f; float num11 = 7f; bool flag = true; bool flag2 = true; int num12 = 120; bool flag3 = false; bool flag4 = false; float num13 = 0.05f; float num14 = 0f; bool flag5 = false; int num15 = npc.type; switch (num15) { case 558: case 559: case 560: flag4 = true; num = 0.7f; if (npc.type == 559) { num = 0.5f; } if (npc.type == 560) { num = 0.2f; } num2 = 3f; scaleFactor = 400f; num3 = 500f; num4 = 90f; num5 = 20f; scaleFactor2 = 0.95f; num6 = 0; scaleFactor3 = 8f; num7 = 30f; num8 = 150f; num9 = 60f; num10 = 0.05f; num11 = 6f; flag2 = false; flag5 = true; break; default: switch (num15) { case 574: case 575: flag4 = true; num = 0.6f; if (npc.type == 575) { num = 0.4f; } num2 = 4f; scaleFactor = 400f; num3 = 500f; num4 = 90f; num5 = 30f; scaleFactor2 = 0.95f; num6 = 3; scaleFactor3 = 8f; num7 = 30f; num8 = 150f; num9 = 10f; num10 = 0.05f; num11 = 0f; num14 = -0.1f; flag3 = true; flag5 = true; break; } break; } NPCAimedTarget targetData = npc.GetTargetData(true); if (flag5) { if (npc.localAI[0] == 0f) { npc.alpha = 255; } if (npc.localAI[0] < 60f) { npc.localAI[0] += 1f; npc.alpha -= 5; if (npc.alpha < 0) { npc.alpha = 0; } int num16 = (int)npc.localAI[0] / 10; float num17 = npc.Size.Length() / 2f; num17 /= 20f; int maxValue = 5; if (npc.type == 576 || npc.type == 577) { maxValue = 1; } for (int i = 0; i < num16; i++) { if (Main.rand.Next(maxValue) == 0) { Dust dust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 27, npc.velocity.X * 1f, 0f, 100, default(Color), 1f); dust.scale = 0.55f; dust.fadeIn = 0.7f; dust.velocity *= 0.1f * num17; dust.velocity += npc.velocity; } } } } if (flag4) { for (int j = 0; j < 200; j++) { if (j != npc.whoAmI && Main.npc[j].active && Main.npc[j].type == npc.type && Math.Abs(npc.position.X - Main.npc[j].position.X) + Math.Abs(npc.position.Y - Main.npc[j].position.Y) < (float)npc.width) { if (npc.position.X < Main.npc[j].position.X) { npc.velocity.X = npc.velocity.X - num13; } else { npc.velocity.X = npc.velocity.X + num13; } if (npc.position.Y < Main.npc[j].position.Y) { npc.velocity.Y = npc.velocity.Y - num13; } else { npc.velocity.Y = npc.velocity.Y + num13; } } } } if (Math.Sign(npc.velocity.X) != 0) { npc.spriteDirection = -Math.Sign(npc.velocity.X); } if (npc.rotation < -1.57079637f) { npc.rotation += 3.14159274f; } if (npc.rotation > 1.57079637f) { npc.rotation -= 3.14159274f; } num10 *= num9; if (Main.expertMode) { num *= Main.expertKnockBack; } if (npc.ai[0] == 0f) { npc.knockBackResist = num; float scaleFactor4 = num2; Vector2 center = npc.Center; Vector2 center2 = targetData.Center; Vector2 vector = center2 - center; Vector2 vector2 = vector - (Vector2.UnitY * scaleFactor); float num18 = vector.Length(); vector = Vector2.Normalize(vector) * scaleFactor4; vector2 = Vector2.Normalize(vector2) * scaleFactor4; bool flag6 = Collision.CanHit(npc.Center, 1, 1, targetData.Center, 1, 1); if (npc.ai[3] >= (float)num12) { flag6 = true; } float num19 = 8f; flag6 = (flag6 && vector.ToRotation() > 3.14159274f / num19 && vector.ToRotation() < 3.14159274f - (3.14159274f / num19)); if (num18 > num3 || !flag6) { npc.velocity.X = ((npc.velocity.X * (num4 - 1f)) + vector2.X) / num4; npc.velocity.Y = ((npc.velocity.Y * (num4 - 1f)) + vector2.Y) / num4; if (!flag6) { npc.ai[3] += 1f; if (npc.ai[3] == (float)num12) { npc.netUpdate = true; } } else { npc.ai[3] = 0f; } } else { npc.ai[0] = 1f; npc.ai[2] = vector.X; npc.ai[3] = vector.Y; npc.netUpdate = true; } } else if (npc.ai[0] == 1f) { npc.knockBackResist = 0f; npc.velocity *= scaleFactor2; npc.velocity.Y = npc.velocity.Y + num14; npc.ai[1] += 1f; if (npc.ai[1] == num5) { npc.localAI[1] = Main.PlayTrackedSound(SoundID.DD2_WyvernDiveDown, npc.Center).ToFloat(); if (Main.rand.Next(5) == 0) { npc.localAI[2] = Main.PlayTrackedSound(SoundID.DD2_WyvernScream, npc.Center).ToFloat(); } } if (npc.ai[1] >= num5) { npc.ai[0] = 2f; npc.ai[1] = 0f; npc.netUpdate = true; Vector2 velocity = new Vector2(npc.ai[2], npc.ai[3]) + (new Vector2((float)Main.rand.Next(-num6, num6 + 1), (float)Main.rand.Next(-num6, num6 + 1)) * 0.04f); velocity.Normalize(); velocity *= scaleFactor3; npc.velocity = velocity; } } else if (npc.ai[0] == 2f) { npc.knockBackResist = 0f; float num20 = num7; npc.ai[1] += 1f; bool flag7 = Vector2.Distance(npc.Center, targetData.Center) > num8 && npc.Center.Y > targetData.Center.Y; if (flag3) { flag7 = false; } if ((npc.ai[1] >= num20 && flag7) || npc.velocity.Length() < num11) { npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; npc.velocity /= 2f; npc.netUpdate = true; if (flag) { npc.ai[1] = 45f; npc.ai[0] = 4f; } } else { Vector2 center3 = npc.Center; Vector2 center4 = targetData.Center; Vector2 vec = center4 - center3; vec.Normalize(); if (vec.HasNaNs()) { vec = new Vector2((float)npc.direction, 0f); } npc.velocity = ((npc.velocity * (num9 - 1f)) + (vec * (npc.velocity.Length() + num10))) / num9; } if (flag2 && Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.ai[0] = 3f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; npc.netUpdate = true; } } else if (npc.ai[0] == 4f) { npc.ai[1] -= 3f; if (npc.ai[1] <= 0f) { npc.ai[0] = 0f; npc.ai[1] = 0f; npc.netUpdate = true; } npc.velocity *= 0.95f; } ActiveSound activeSound2 = Main.GetActiveSound(SlotId.FromFloat(npc.localAI[1])); if (activeSound2 != null) { activeSound2.Position = npc.Center; } else { npc.localAI[1] = SlotId.Invalid.ToFloat(); } activeSound2 = Main.GetActiveSound(SlotId.FromFloat(npc.localAI[2])); if (activeSound2 != null) { activeSound2.Position = npc.Center; } else { npc.localAI[2] = SlotId.Invalid.ToFloat(); } if (flag2 && npc.ai[0] != 3f && Vector2.Distance(npc.Center, targetData.Center) < 64f) { npc.ai[0] = 3f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; npc.netUpdate = true; } if (npc.ai[0] == 3f) { npc.position = npc.Center; npc.width = (npc.height = 192); npc.position.X = npc.position.X - (float)(npc.width / 2); npc.position.Y = npc.position.Y - (float)(npc.height / 2); npc.velocity = Vector2.Zero; npc.damage = (int)(80f * Main.damageMultiplier); npc.alpha = 255; if (npc.ai[1] == 0f && (npc.type == 574 || npc.type == 575)) { for (int k = 0; k < 4; k++) { int num21 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 31, 0f, 0f, 100, default(Color), 1.5f); Main.dust[num21].position = npc.Center + (Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)npc.width / 2f); } for (int l = 0; l < 20; l++) { int num22 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 6, 0f, 0f, 200, default(Color), 3.7f); Main.dust[num22].position = npc.Center + (Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)npc.width / 2f); Main.dust[num22].noGravity = true; Main.dust[num22].velocity *= 3f; num22 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 1.5f); Main.dust[num22].position = npc.Center + (Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)npc.width / 4f); Main.dust[num22].velocity *= 2f; Main.dust[num22].noGravity = true; Main.dust[num22].fadeIn = 2.5f; } for (int m = 0; m < 6; m++) { int num23 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 6, 0f, 0f, 0, default(Color), 2.7f); Main.dust[num23].position = npc.Center + (Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)npc.velocity.ToRotation(), default(Vector2)) * (float)npc.width / 2f); Main.dust[num23].noGravity = true; Main.dust[num23].velocity *= 3f; } for (int n = 0; n < 12; n++) { int num24 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 31, 0f, 0f, 0, default(Color), 1.5f); Main.dust[num24].position = npc.Center + (Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)npc.velocity.ToRotation(), default(Vector2)) * (float)npc.width / 2f); Main.dust[num24].noGravity = true; Main.dust[num24].velocity *= 3f; } for (int num25 = 0; num25 < 5; num25++) { int num26 = Gore.NewGore(npc.position + new Vector2((float)(npc.width * Main.rand.Next(100)) / 100f, (float)(npc.height * Main.rand.Next(100)) / 100f) - (Vector2.One * 10f), default(Vector2), Main.rand.Next(61, 64), 1f); Main.gore[num26].position = npc.Center + (Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)npc.width / 2f); Main.gore[num26].velocity *= 0.3f; Gore expr_128A_cp_0 = Main.gore[num26]; expr_128A_cp_0.velocity.X = expr_128A_cp_0.velocity.X + ((float)Main.rand.Next(-10, 11) * 0.05f); Gore expr_12B8_cp_0 = Main.gore[num26]; expr_12B8_cp_0.velocity.Y = expr_12B8_cp_0.velocity.Y + ((float)Main.rand.Next(-10, 11) * 0.05f); } } npc.ai[1] += 1f; if (npc.ai[1] >= 3f) { Main.PlaySound(SoundID.Item14, npc.position); npc.life = 0; npc.HitEffect(0, 10.0); npc.active = false; } } }
public override void AI() { GetVariationValues(out int variation, out float fakeCounter, out float counterMax); float fromValue = fakeCounter / counterMax; if (fakeCounter == 0f) { Projectile.localAI[1] = SoundEngine.PlayTrackedSound(SoundID.DD2_GhastlyGlaiveImpactGhost, Projectile.Center).ToFloat(); } ActiveSound activeSound = SoundEngine.GetActiveSound(SlotId.FromFloat(Projectile.localAI[1])); if (activeSound == null) { Projectile.localAI[1] = SlotId.Invalid.ToFloat(); } else { activeSound.Position = Projectile.Center; } float fadeOutTime = counterMax - 15f; if (fakeCounter > fadeOutTime) { Projectile.alpha += 25; if (Projectile.alpha > 255) { Projectile.alpha = 255; } } else { Projectile.alpha -= 25; if (Projectile.alpha < 50) { Projectile.alpha = 50; } } if (fakeCounter >= counterMax - 1f) { Projectile.Kill(); return; } if (variation == 0) { Projectile.velocity *= 0.98f; Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); Projectile.rotation = Projectile.velocity.ToRotation(); if (Projectile.spriteDirection == -1) { Projectile.rotation += MathHelper.Pi; } } else if (variation == 1) { float offset = 70f; Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); if (Projectile.velocity.Length() > 0.1f) { Projectile.velocity *= 0.95f; } offset *= Projectile.direction; Vector2 value = Projectile.Center - Projectile.rotation.ToRotationVector2() * offset; float from03to05 = Utils.Remap(fromValue, 0.3f, 0.5f, 0f, 1f) * Utils.Remap(fromValue, 0.45f, 0.5f, 1f, 0f); //Wind-up float from05to1 = Utils.Remap(fromValue, 0.5f, 0.55f, 0f, 1f) * Utils.Remap(fromValue, 0.5f, 1f, 1f, 0f); //Swing float bonusRot = from03to05 * MathHelper.Pi / 60f; bonusRot += from05to1 * -MathHelper.Pi * 8f / 60f; Projectile.rotation += bonusRot * -Projectile.direction; Projectile.rotation = MathHelper.WrapAngle(Projectile.rotation); Projectile.Center = value + Projectile.rotation.ToRotationVector2() * offset; } else if (variation == 2) { float f = Projectile.ai[1]; float from0to04 = Utils.Remap(fromValue, 0f, 0.4f, 1f, 0f); float from03to1 = Utils.Remap(fromValue, 0.3f, 0.4f, 0f, 1f) * Utils.Remap(fromValue, 0.4f, 1f, 1f, 0f); float velocityFactor = from0to04 * 2f + from03to1 * 8f + 0.01f; Projectile.velocity = f.ToRotationVector2() * velocityFactor; Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); Projectile.rotation = Projectile.velocity.ToRotation(); if (Projectile.spriteDirection == -1) { Projectile.rotation += MathHelper.Pi; } } else if (variation == 3) { float num8 = Projectile.ai[1]; Projectile.velocity = Projectile.velocity.RotatedBy(num8); Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); Projectile.rotation = Projectile.velocity.ToRotation(); if (Projectile.spriteDirection == -1) { Projectile.rotation += MathHelper.Pi; } } Projectile.ai[0] += 1f; }
public override void AI() { float progress = Counter / Lifetime; if (Counter == 0f) { SoundSlot = SoundEngine.PlayTrackedSound(SoundID.DD2_GhastlyGlaiveImpactGhost, Projectile.Center).ToFloat(); } ActiveSound activeSound = SoundEngine.GetActiveSound(SlotId.FromFloat(SoundSlot)); if (activeSound == null) { SoundSlot = SlotId.Invalid.ToFloat(); } else { activeSound.Position = Projectile.Center; } float fadeOutTime = Lifetime - 15f; if (Counter > fadeOutTime) { Projectile.alpha += 10; if (Projectile.alpha > 255) { Projectile.alpha = 255; } } else { Projectile.alpha -= 25; if (Projectile.alpha < 50) { Projectile.alpha = 50; } } if (Counter >= Lifetime - 1f) { Projectile.Kill(); return; } float offset = 70f; Projectile.direction = Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); if (Projectile.velocity.Length() > 0.1f) { Projectile.velocity *= 0.95f; } offset *= Projectile.direction; Vector2 value = Projectile.Center - Projectile.rotation.ToRotationVector2() * offset; float windUp = Utils.Remap(progress, 0.3f, 0.5f, 0f, 1f) * Utils.Remap(progress, 0.45f, 0.5f, 1f, 0f); float swing = Utils.Remap(progress, 0.5f, 0.55f, 0f, 1f) * Utils.Remap(progress, 0.5f, 0.95f, 1f, 0.05f); float bonusRot = windUp * MathHelper.Pi / 60f; bonusRot += swing * -MathHelper.Pi * 5.5f / 60f; Projectile.rotation += bonusRot * -Projectile.direction; Projectile.rotation = MathHelper.WrapAngle(Projectile.rotation); Projectile.Center = value + Projectile.rotation.ToRotationVector2() * offset; Counter += 1f; }
public override void AI() { float num = 300f; if (projectile.soundDelay == 0) { projectile.soundDelay = -1; projectile.localAI[1] = Main.PlayTrackedSound(SoundID.DD2_BookStaffTwisterLoop, projectile.Center).ToFloat(); } ActiveSound activeSound = Main.GetActiveSound(SlotId.FromFloat(projectile.localAI[1])); if (activeSound != null) { activeSound.Position = projectile.Center; activeSound.Volume = 1f - Math.Max(projectile.ai[0] - (num - 15f), 0f) / 15f; } else { projectile.localAI[1] = SlotId.Invalid.ToFloat(); } if (projectile.localAI[0] >= 16f && projectile.ai[0] < num - 15f) { projectile.ai[0] = num - 15f; } projectile.ai[0] += 1f; if (projectile.ai[0] >= num) { projectile.Kill(); } Vector2 top = projectile.Top; Vector2 bottom = projectile.Bottom; Vector2 value = Vector2.Lerp(top, bottom, 0.5f); Vector2 value2 = new Vector2(0f, bottom.Y - top.Y); value2.X = value2.Y * 0.2f; int num2 = 16; int num3 = 160; for (int i = 0; i < 1; i++) { Vector2 position = new Vector2(projectile.Center.X - num2 / 2, projectile.position.Y + projectile.height - num3); if (Collision.SolidCollision(position, num2, num3) || Collision.WetCollision(position, num2, num3)) { if (projectile.velocity.Y > 0f) { projectile.velocity.Y = 0f; } if (projectile.velocity.Y > -4f) { projectile.velocity.Y = projectile.velocity.Y - 2f; } else { projectile.velocity.Y = projectile.velocity.Y - 4f; projectile.localAI[0] += 2f; } if (projectile.velocity.Y < -16f) { projectile.velocity.Y = -16f; } } else { projectile.localAI[0] -= 1f; if (projectile.localAI[0] < 0f) { projectile.localAI[0] = 0f; } if (projectile.velocity.Y < 0f) { projectile.velocity.Y = 0f; } if (projectile.velocity.Y < 4f) { projectile.velocity.Y = projectile.velocity.Y + 2f; } else { projectile.velocity.Y = projectile.velocity.Y + 4f; } if (projectile.velocity.Y > 16f) { projectile.velocity.Y = 16f; } } } if (projectile.ai[0] < num - 30f) { for (int j = 0; j < 1; j++) { float value3 = -1f; float value4 = 0.9f; float amount = Main.rand.NextFloat(); Vector2 value5 = new Vector2(MathHelper.Lerp(0.1f, 1f, Main.rand.NextFloat()), MathHelper.Lerp(value3, value4, amount)); value5.X *= MathHelper.Lerp(2.2f, 0.6f, amount); value5.X *= -1f; Vector2 value6 = new Vector2(6f, 10f); Vector2 position2 = value + value2 * value5 * 0.5f + value6; Dust dust = Main.dust[Dust.NewDust(position2, 0, 0, 269, 0f, 0f, 0, default, 1f)];