diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 02ef1fefa3..8f2056546b 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -202,6 +202,10 @@ namespace CalamityMod.CalPlayer { Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Player.Center.DirectionTo(Player.Calamity().mouseWorld), ModContent.ProjectileType(), Player.HeldItem.damage, Player.HeldItem.knockBack, Player.whoAmI); } + if (Player.whoAmI == Main.myPlayer && Player.HeldItem.type == ModContent.ItemType() && Player.ownedProjectileCounts[ModContent.ProjectileType()] == 0 && !Player.dead) + { + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Player.Center.DirectionTo(Player.Calamity().mouseWorld), ModContent.ProjectileType(), Player.HeldItem.damage, Player.HeldItem.knockBack, Player.whoAmI); + } // De-equipping Gael's Greatsword deletes all rage. if (Player.ActiveItem().type == ModContent.ItemType()) diff --git a/ExtraTextures/SimpleStar.png b/ExtraTextures/SimpleStar.png new file mode 100644 index 0000000000..15fe40013a Binary files /dev/null and b/ExtraTextures/SimpleStar.png differ diff --git a/Items/Weapons/Ranged/Starfleet.cs b/Items/Weapons/Ranged/Starfleet.cs index 2ee98917d3..b5c1cb0594 100644 --- a/Items/Weapons/Ranged/Starfleet.cs +++ b/Items/Weapons/Ranged/Starfleet.cs @@ -1,9 +1,13 @@ -using CalamityMod.Items.Materials; +using System.Collections.Generic; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using System.Linq; +using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Ranged { @@ -23,7 +27,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.knockBack = 15f; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.rare = ModContent.RarityType(); - Item.UseSound = SoundID.Item92; Item.channel = true; Item.noUseGraphic = true; Item.autoReuse = true; @@ -33,13 +36,35 @@ namespace CalamityMod.Items.Weapons.Ranged } // Holdout projectile is spawned when holding the item, so using the item does nothing public override bool CanUseItem(Player player) => false; + public override void ModifyTooltips(List list) + { + Player Owner = Main.LocalPlayer; + if (Owner is null) + return; + float rate = (Main.GlobalTimeWrappedHourly * 3); + List eColors = new List() + { + new Color(164, 47, 160), + new Color(227, 97, 72), + new Color(193, 255, 146) + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color eTooltipColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip7"); + if (line != null) + line.OverrideColor = Color.Lerp(eTooltipColor, Color.White, 0.2f); + } public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.SuperStarCannon). - AddIngredient(). AddIngredient(4). - AddTile(TileID.MythrilAnvil). + AddIngredient(ItemID.FallenStar, 15). + AddIngredient(3). + AddIngredient(25). + AddTile(TileID.LunarCraftingStation). Register(); } } diff --git a/Items/Weapons/Ranged/Starfleet.png b/Items/Weapons/Ranged/Starfleet.png index 077683647b..5a37c419bb 100644 Binary files a/Items/Weapons/Ranged/Starfleet.png and b/Items/Weapons/Ranged/Starfleet.png differ diff --git a/Items/Weapons/Ranged/StarfleetGlow.png b/Items/Weapons/Ranged/StarfleetGlow.png index 828abd303e..e501e70a46 100644 Binary files a/Items/Weapons/Ranged/StarfleetGlow.png and b/Items/Weapons/Ranged/StarfleetGlow.png differ diff --git a/Items/Weapons/Ranged/Starmada.cs b/Items/Weapons/Ranged/Starmada.cs index 9960e8e68f..cf441eb803 100644 --- a/Items/Weapons/Ranged/Starmada.cs +++ b/Items/Weapons/Ranged/Starmada.cs @@ -1,14 +1,14 @@ -using CalamityMod.Items.Materials; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Projectiles.Ranged; -using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; -using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Ranged { @@ -20,53 +20,50 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 122; Item.height = 50; - Item.damage = 150; + Item.damage = 3050; Item.DamageType = DamageClass.Ranged; - Item.useAnimation = Item.useTime = 15; + Item.useAnimation = Item.useTime = 70; Item.knockBack = 15f; Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = SoundID.Item92; - Item.autoReuse = true; Item.noMelee = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 16f; + Item.channel = true; + Item.noUseGraphic = true; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 12f; Item.useAmmo = AmmoID.FallenStar; Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; } - - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextBool(3); - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + // Holdout projectile is spawned when holding the item, so using the item does nothing + public override bool CanUseItem(Player player) => false; + public override void ModifyTooltips(List list) { - for (int i = 0; i < 5; i++) + Player Owner = Main.LocalPlayer; + if (Owner is null) + return; + float rate = (Main.GlobalTimeWrappedHourly * 3); + List eColors = new List() { - int starType = Utils.SelectRandom(Main.rand, - [ - ModContent.ProjectileType(), - ModContent.ProjectileType(), - ProjectileID.StarCannonStar, - ProjectileID.Starfury - ]); - int star = Projectile.NewProjectile(source, position + Main.rand.NextVector2Circular(21f, 21f), velocity * Main.rand.NextFloat(0.8f, 1.2f), starType, damage, knockback, player.whoAmI); - if (star.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[star].penetrate = 1; - Main.projectile[star].timeLeft = 300; - Main.projectile[star].DamageType = DamageClass.Ranged; - Main.projectile[star].netUpdate = true; - } - } - return false; - } + new Color(164, 47, 160), + new Color(227, 97, 72), + new Color(193, 255, 146) + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color eTooltipColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip9"); + if (line != null) + line.OverrideColor = Color.Lerp(eTooltipColor, Color.White, 0.2f); + } public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(). - AddIngredient(8). - AddIngredient(8). + AddIngredient(ItemID.SuperStarCannon). + AddIngredient(5). AddIngredient(15). AddTile(). Register(); diff --git a/Items/Weapons/Ranged/Starmada.png b/Items/Weapons/Ranged/Starmada.png index 3cef0ffadf..b9c45f34cb 100644 Binary files a/Items/Weapons/Ranged/Starmada.png and b/Items/Weapons/Ranged/Starmada.png differ diff --git a/Items/Weapons/Ranged/StarmadaGlow.png b/Items/Weapons/Ranged/StarmadaGlow.png new file mode 100644 index 0000000000..f7d1a7365e Binary files /dev/null and b/Items/Weapons/Ranged/StarmadaGlow.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 2d767078ac..140ec928f0 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -1196,15 +1196,33 @@ Spyker: { Starfleet: { DisplayName: Starfleet - Tooltip: Fires a spread of plasma blasts + Tooltip: + ''' + Fires a spread of starshots + Fires a concussive short range starburst + Holding down disables the recoil damper + Starshots can be accelerated by firing when the starburst goes off + Perfect timing reduces spread and increases damage + Imperfect timing still increases damage, but heavily increases spread + Uses fallen stars, 50% chance to save ammo + 'Etoile, et toi' + ''' } Starmada: { DisplayName: Starmada Tooltip: ''' - Fires a barrage of stars and plasma blasts - 66% chance to save ammo + Fires a spread of starshots + Fires a concussive short range starburst + Holding down disables the recoil damper + Starshots create stardrops on impact + Stardrops can be hit with the starburst to be launched back into enemies + Starshots can be accelerated by firing when the starburst goes off + Perfect timing reduces spread and increases damage + Imperfect timing still increases damage, but heavily increases spread + Uses fallen stars, 50% chance to save ammo + 'Et toi, et moi' ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 66ee2e8c71..109ab32725 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -264,3 +264,5 @@ SulphuricDrop.DisplayName: Sulphuric Drop AcidRocket.DisplayName: Acid Rocket M1GarandBulletCasing.DisplayName: M1 Garand Bullet Casing M1GarandEmptyClip.DisplayName: M1 Garand Empty Clip +StarmadaHitProj.DisplayName: Starmada Hit Proj +StarmadaStar.DisplayName: Starmada Star diff --git a/Projectiles/Ranged/StarfleetHoldout.cs b/Projectiles/Ranged/StarfleetHoldout.cs index b7fa58e6cb..cdbc3f59a7 100644 --- a/Projectiles/Ranged/StarfleetHoldout.cs +++ b/Projectiles/Ranged/StarfleetHoldout.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; @@ -38,9 +39,10 @@ namespace CalamityMod.Projectiles.Ranged public Vector2 recoilDirection; public bool setVel = true; public float glowIntensity = 1; - public Color c1 = new Color (192, 10, 111); - public Color c2 = Color.Coral; - public Color c3 = Color.DarkOrange; + public Color c1 = new Color(164, 47, 160); + public Color c2 = new Color(227, 97, 72); + public Color c3 = new Color(193, 255, 146); + public Color shiftColor; public ref float starburstCooldown => ref Projectile.ai[2]; public bool naildriver => ((starburstTimer <= starburstPerfectTime + perfectLeniancy) && (starburstTimer >= starburstPerfectTime - perfectLeniancy)); // if within perfect frame window public bool scattershot => !naildriver && ((starburstTimer <= starburstPerfectTime + goodLeniancy) && (starburstTimer >= starburstPerfectTime - goodLeniancy)); // If within early or late frame window @@ -55,6 +57,18 @@ namespace CalamityMod.Projectiles.Ranged } public override void HoldoutAI() { + float rate = (time * 0.05f); + List eColors = new List() + { + c1, + c2, + c3, + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + SetUsage = false; bool doingNothing = shootingCooldown == 0 && starburstCooldown == 0 && starburstTimer == 0; if (lastUseTime == 0 || doingNothing) @@ -85,7 +99,7 @@ namespace CalamityMod.Projectiles.Ranged if (starburstTimer < starburstPerfectTime / 2) OffsetLengthFromArm = 25 - 12 * (1 - (float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2 - 1, 0, starburstTimer, true), 5)); else - OffsetLengthFromArm = 18 + 20 * ((float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2, starburstPerfectTime - 1, starburstTimer, true), 8)); + OffsetLengthFromArm = 13 + 20 * ((float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2, starburstPerfectTime - 1, starburstTimer, true), 8)); if (starburstTimer == starburstPerfectTime) FireStarburst(); @@ -106,7 +120,7 @@ namespace CalamityMod.Projectiles.Ranged { float slowdown = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4); Vector2 movement = recoilDirection * (recoilIntensity) * slowdown; - if (Collision.SolidCollision(Owner.Center + movement, (int)(Owner.width * 1.1f), (int)(Owner.height * 1.1f))) + if (Collision.SolidCollision(Owner.Center + movement, (int)(Owner.width * 1.1f), (int)(Owner.height * 1.1f)) || !Owner.Calamity().mouseRight) { recoilIntensity = 0; return; @@ -129,9 +143,9 @@ namespace CalamityMod.Projectiles.Ranged // 50% chance to not consume ammo Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _, Main.rand.NextBool()); - SoundStyle shotgunFire = new("CalamityMod/Sounds/Item/StarmadaFire"); + SoundStyle shotgunFire = new("CalamityMod/Sounds/Item/StarfleetFire"); for (int i = 0; i < (naildriver ? 2 : 1); i++) - SoundEngine.PlaySound(shotgunFire with { Volume = 0.7f, Pitch = ((naildriver && i == 0) ? -0.2f : 0f), MaxInstances = 2 }, Projectile.Center); + SoundEngine.PlaySound(shotgunFire with { Volume = 0.7f, Pitch = ((naildriver && i == 0) ? 0f : 0.2f), MaxInstances = 2 }, Projectile.Center); // Perfects have longer cooldown int cooldown = (naildriver ? naildriverCooldown : lastUseTime); recoilTimerMax = cooldown; @@ -142,10 +156,10 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 6; i++) { - float randomVel = Main.rand.NextFloat(0.7f, 1.1f); + float randomVel = Main.rand.NextFloat(0.8f, 1f); float damageMult = (naildriver || scattershot) ? 2f : 1f; float spread = (naildriver ? 0.06f : scattershot ? 0.9f : 0.25f); - Projectile shotgun = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, randomVel * Projectile.velocity.RotatedByRandom(spread) * 8, ModContent.ProjectileType(), (int)(Projectile.damage * damageMult), Projectile.knockBack, Projectile.owner); + Projectile shotgun = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, randomVel * Projectile.velocity.RotatedByRandom(spread) * 8, ModContent.ProjectileType(), (int)(Projectile.damage * damageMult), Projectile.knockBack, Projectile.owner, 0, 0, Main.rand.Next(0, 300 + 1)); shotgun.extraUpdates = naildriver ? 9 : scattershot ? 7 : 3; } for (int i = 0; i < 25; i++) @@ -156,7 +170,7 @@ namespace CalamityMod.Projectiles.Ranged dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 3f; dust.velocity = Projectile.velocity.RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2); dust.noGravity = true; - dust.color = Color.Lerp(c1, c3, Main.rand.NextFloat(0f, 1f)); + dust.color = GetRandomColor(); dust.fadeIn = 4.75f; } @@ -172,8 +186,6 @@ namespace CalamityMod.Projectiles.Ranged { if (Owner.Calamity().GeneralScreenShakePower < 7) Owner.Calamity().GeneralScreenShakePower = 7; - if (OffsetLengthFromArm > 10) - OffsetLengthFromArm = 10; recoilDirection = -Projectile.velocity; if (recoilIntensity < 15) recoilIntensity = 15; @@ -191,14 +203,14 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 14; i++) { float dist = Main.rand.NextFloat(0, 3); - Particle forwardJet = new CustomSpark(GunTipPosition + Main.rand.NextVector2CircularEdge(dist * 5, dist * 5), Projectile.velocity * Main.rand.NextFloat(4, 5) * (6 - dist * 2), "CalamityMod/Particles/ForwardSmear", false, (int)(Main.rand.Next(9, 15 + 1) + (dist * 3)), Main.rand.NextFloat(0.1f, 0.2f), Color.Lerp(c1, c3, Main.rand.NextFloat(0f, 1f)), new Vector2(1f, 1f), shrinkSpeed: 0.3f); + Particle forwardJet = new CustomSpark(GunTipPosition + Main.rand.NextVector2CircularEdge(dist * 5, dist * 5), Projectile.velocity * Main.rand.NextFloat(4, 5) * (6 - dist * 2), "CalamityMod/Particles/ForwardSmear", false, (int)(Main.rand.Next(9, 15 + 1) + (dist * 3)), Main.rand.NextFloat(0.1f, 0.2f), GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: 0.3f); GeneralParticleHandler.SpawnParticle(forwardJet); } for (int i = 0; i < 34; i++) { float rot = Main.rand.NextFloat(0.05f, 0.35f) * (Main.rand.NextBool() ? -1 : 1); Vector2 startVel = Projectile.velocity.RotatedBy(rot) * Main.rand.NextFloat(8, 18) * (Main.rand.NextBool(4) ? 2f : 1); - Particle stars = new VelChangingSpark(GunTipPosition, startVel, startVel.RotatedBy(rot * 5), "CalamityMod/Particles/PulseStar", Main.rand.Next(25, 45 + 1), Main.rand.NextFloat(0.1f, 0.35f), Color.Lerp(c1, c3, Main.rand.NextFloat(0f, 1f)), new Vector2(1f, 1f), shrinkSpeed: Main.rand.NextFloat(0.02f, 0.06f), lerpRate: 0.02f, glowCenter: true); + Particle stars = new VelChangingSpark(GunTipPosition, startVel, startVel.RotatedBy(rot * 5), "CalamityMod/Particles/PulseStar", Main.rand.Next(25, 45 + 1), Main.rand.NextFloat(0.1f, 0.35f), GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: Main.rand.NextFloat(0.02f, 0.06f), lerpRate: 0.02f, glowCenter: true); GeneralParticleHandler.SpawnParticle(stars); } int parts = 60; @@ -211,12 +223,23 @@ namespace CalamityMod.Projectiles.Ranged float size = Utils.GetLerpValue(0, -4, intenededVel.X, true); float width = Utils.GetLerpValue(0, 4 * Math.Sign(fxVel.X), fxVel.X, true); + Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f)); - Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(15 + size * 5), 0.35f + size * 0.2f, Color.Lerp(c1, c3, Main.rand.NextFloat(0f, 1f)) * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f); + Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(15 + size * 5), 0.35f + size * 0.2f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f); GeneralParticleHandler.SpawnParticle(aura); } } + public Color GetRandomColor() + { + Color useColor = Main.rand.Next(4) switch + { + 0 => c1, + 1 => c2, + _ => c3, + }; + return useColor; + } public override bool PreDraw(ref Color lightColor) { if (time < 2) @@ -236,14 +259,14 @@ namespace CalamityMod.Projectiles.Ranged float attackMult = (float)Math.Pow(Utils.GetLerpValue(0, starburstPerfectTime - 1, starburstTimer, true), 2); float sine2 = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 55.5f / MathHelper.Pi); float fastSine = (float)Math.Sin(time * 0.2f); - Color glowColor = Color.Lerp(c2, c3, 1 + sine); + Color glowColor = shiftColor; if (starburstTimer > 0 && starburstCooldown == 0) { for (int i = 0; i < draws; i++) { Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time * 2); - Main.EntitySpriteDraw(texture, drawPosition + drawOffset * 6 * attackMult, null, c2 with { A = 0 } * 0.7f * attackMult, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(texture, drawPosition + drawOffset * 6 * attackMult, null, shiftColor with { A = 0 } * 0.7f * attackMult, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); } } @@ -260,9 +283,9 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i < 6; i++) { - // the electric orb at the tip - Color orbColor = Color.Lerp(Color.Lerp(c1, c3, (i + 2) / 6), Color.White, i / 6) with { A = 0 } * 0.5f; - Vector2 scale = new Vector2(Math.Abs(sine2 * 0.5f) + 0.1f, 1) * (0.05f + i * 0.01f) * attackMult * Main.rand.NextFloat(0.9f, 1.1f) * 5; + // The shining orb at the tip + Color orbColor = shiftColor with { A = 0 } * 0.5f; + Vector2 scale = new Vector2(Math.Abs(sine2 * 0.5f) + 0.1f, 1) * (0.05f + i * 0.01f) * attackMult * Main.rand.NextFloat(0.9f, 1.1f) * 8.5f; Main.EntitySpriteDraw(orb, GunTipPosition - Main.screenPosition, null, orbColor, Main.rand.NextFloat(-5, 5), orb.Size() * 0.5f, scale, SpriteEffects.None); } } diff --git a/Projectiles/Ranged/StarfleetStar.cs b/Projectiles/Ranged/StarfleetStar.cs index edc0ef35cc..8bf5689f27 100644 --- a/Projectiles/Ranged/StarfleetStar.cs +++ b/Projectiles/Ranged/StarfleetStar.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; @@ -15,9 +16,10 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public int time = 0; - public Color c1 = new Color(192, 10, 111); - public Color c2 = Color.Coral; - public Color c3 = Color.DarkOrange; + public Color c1 = new Color(164, 47, 160); + public Color c2 = new Color(227, 97, 72); + public Color c3 = new Color(193, 255, 146); + public Color shiftColor; public Player Owner => Main.player[Projectile.owner]; public override void SetDefaults() { @@ -36,9 +38,22 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + float rate = (Projectile.ai[2] * 0.05f); + List eColors = new List() + { + c1, + c2, + c3, + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + Projectile.ai[2]++; + if (time > 5 && time % 2 == 0) { - Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/DualTrail", false, 15, 0.11f, Color.Lerp(c1, c3, Main.rand.NextFloat(0f, 1f)), new Vector2(0.9f, 1.1f), shrinkSpeed: 0.5f); + Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/DualTrail", false, 15, 0.11f, shiftColor, new Vector2(0.9f, 1.1f), shrinkSpeed: 0.5f); GeneralParticleHandler.SpawnParticle(trail); if (time > 18) @@ -48,13 +63,23 @@ namespace CalamityMod.Projectiles.Ranged dust.scale = Main.rand.NextFloat(1.2f, 1.8f); dust.velocity = -Projectile.velocity * Main.rand.NextFloat(3f, 5f); dust.noGravity = true; - dust.color = Color.Lerp(c1, c3, Main.rand.NextFloat(0f, 1f)); + dust.color = shiftColor; dust.fadeIn = 5f; } } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; time++; } + public Color GetRandomColor() + { + Color useColor = Main.rand.Next(4) switch + { + 0 => c1, + 1 => c2, + _ => c3, + }; + return useColor; + } public override bool PreDraw(ref Color lightColor) { Texture2D glowTexture = Request("CalamityMod/Projectiles/Rogue/LeonidStar").Value; @@ -65,17 +90,11 @@ namespace CalamityMod.Projectiles.Ranged Vector2 rotationPoint = glowTexture.Size() * 0.5f; SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - int draws = 18; - float sine = (float)Math.Sin(time * 0.02f); - float fastSine = (float)Math.Sin(time * 0.3f); - Color glowColor = Color.Lerp(c1, c3, 1 + sine); - Vector2 stretch = new Vector2(1f, 1f) * 0.8f; - for (int i = 0; i < 5; i++) { Vector2 offset = (MathHelper.TwoPi * i / 5).ToRotationVector2().RotatedBy(Projectile.rotation + MathHelper.Pi); for (int t = 0; t < 3; t++) - Main.EntitySpriteDraw(tex2, drawPosition, null, Color.Lerp(c1, c3, t / 2f) with { A = 0 }, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2((2.3f + t * 0.03f) * (i == 2 ? 1.8f : i == 3 ? 1.8f : 1), (1.1f + t * 0.03f) * (i == 2 ? 0.75f : i == 3 ? 0.75f : 1)) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically); + Main.EntitySpriteDraw(tex2, drawPosition, null, shiftColor with { A = 0 }, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2((2.3f + t * 0.03f) * (i == 2 ? 1.8f : i == 3 ? 1.8f : 1), (1.1f + t * 0.03f) * (i == 2 ? 0.75f : i == 3 ? 0.75f : 1)) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically); Main.EntitySpriteDraw(tex2, drawPosition, null, Color.White with { A = 0 }, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2(1.5f, 0.7f) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically); } return false; @@ -97,7 +116,7 @@ namespace CalamityMod.Projectiles.Ranged dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 1.5f; dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2); dust.noGravity = true; - dust.color = Color.Lerp(c1, c3, Main.rand.NextFloat(0f, 1f)); + dust.color = GetRandomColor(); dust.fadeIn = 2.5f; } } diff --git a/Projectiles/Ranged/StarmadaBack.png b/Projectiles/Ranged/StarmadaBack.png new file mode 100644 index 0000000000..0ab54481ce Binary files /dev/null and b/Projectiles/Ranged/StarmadaBack.png differ diff --git a/Projectiles/Ranged/StarmadaBackGlow.png b/Projectiles/Ranged/StarmadaBackGlow.png new file mode 100644 index 0000000000..b1eee4a7ab Binary files /dev/null and b/Projectiles/Ranged/StarmadaBackGlow.png differ diff --git a/Projectiles/Ranged/StarmadaFront.png b/Projectiles/Ranged/StarmadaFront.png new file mode 100644 index 0000000000..56513025f1 Binary files /dev/null and b/Projectiles/Ranged/StarmadaFront.png differ diff --git a/Projectiles/Ranged/StarmadaFrontGlow.png b/Projectiles/Ranged/StarmadaFrontGlow.png new file mode 100644 index 0000000000..8a230dbe1f Binary files /dev/null and b/Projectiles/Ranged/StarmadaFrontGlow.png differ diff --git a/Projectiles/Ranged/StarmadaHitProj.cs b/Projectiles/Ranged/StarmadaHitProj.cs new file mode 100644 index 0000000000..2a8911fea4 --- /dev/null +++ b/Projectiles/Ranged/StarmadaHitProj.cs @@ -0,0 +1,220 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Build.Construction; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class StarmadaHitProj : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public Color c1 = new Color(164, 47, 160); + public Color c2 = new Color(227, 97, 72); + public Color c3 = new Color(193, 255, 146); + public Color shiftColor; + public bool move = false; + public NPC targeted; + public Vector2 targetPos; + public Vector2 distFromPos; + public float squash = 1; + public bool launched => Projectile.localAI[2] == 5 && move; + public bool setLaunchStats = true; + public Player Owner => Main.player[Projectile.owner]; + public override void SetDefaults() + { + Projectile.width = 25; + Projectile.height = 25; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 3; + Projectile.penetrate = -1; + Projectile.timeLeft = 600; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = false; + } + public void FindTarget() + { + if (Projectile.ai[0] != -5) + targeted = Main.npc[(int)Projectile.ai[0]]; + if (targeted == null || !targeted.CanBeChasedBy(Projectile, false) || !targeted.active) + { + targeted = Projectile.Center.ClosestNPCAt(800); + Projectile.ai[0] = -5; + } + } + + public override void AI() + { + if (time == 0) + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + targetPos = Projectile.Center; + } + float rate = (Projectile.ai[2] * 0.05f); + List eColors = new List() + { + c1, + c2, + c3, + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + Projectile.ai[2]++; + + + if (time > 5 && time % 2 == 0) + { + + //Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/DualTrail", false, 15, 0.11f, shiftColor, new Vector2(0.9f, 1.1f), shrinkSpeed: 0.5f); + //GeneralParticleHandler.SpawnParticle(trail); + + + if (time > 18) + { + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), dustStyle); + dust.scale = Main.rand.NextFloat(1.2f, 1.8f); + dust.velocity = -Projectile.velocity * Main.rand.NextFloat(3f, 5f); + dust.noGravity = true; + dust.color = shiftColor; + dust.fadeIn = 5f; + } + } + + + + float startTime = 120 + Projectile.ai[1]; + float endTime = startTime + 15 + Projectile.ai[1]; + if (launched) + { + if (setLaunchStats) + { + time = 0; + Projectile.penetrate = 1; + for (int i = 0; i < Main.maxNPCs; i++) + Projectile.localNPCImmunity[i] = 0; + + setLaunchStats = false; + } + Projectile.rotation += (MathHelper.TwoPi) / (endTime / 3); + Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/BloomCircle", false, 15, 0.3f, shiftColor, new Vector2(0.8f, 1.3f), shrinkSpeed: 0.5f); + GeneralParticleHandler.SpawnParticle(trail); + if (time > 10) + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, 0.6f, 25, 0.9f + (Utils.GetLerpValue(200, 0, time, true) * 0.1f)); + } + else + { + if (move) + { + squash = MathHelper.Lerp(squash, (time < endTime ? 0.15f : 1f), 0.08f); + if (time == endTime) + Projectile.localAI[2] = 1; + if (time >= endTime) + { + Projectile.Center += Projectile.velocity.SafeNormalize(Vector2.UnitX) * 0.2f; + if (time < endTime * 2f) + Projectile.velocity *= 0.9f + (Projectile.ai[1] * 0.005f); + + Projectile.rotation += (MathHelper.TwoPi) / (endTime / 3); + } + else + { + Projectile.rotation = Projectile.rotation.AngleLerp(Projectile.velocity.ToRotation() + MathHelper.PiOver2, 0.1f); + Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/BloomCircle", false, 15, 0.3f, shiftColor, new Vector2(0.8f, 1.3f), shrinkSpeed: 0.5f); + GeneralParticleHandler.SpawnParticle(trail); + } + } + else + { + Projectile.rotation += MathHelper.TwoPi / (startTime / 3); + + FindTarget(); + if (targeted != null) + { + targetPos = targeted.Center; + } + if (distFromPos != Vector2.Zero) + { + Projectile.Center = targetPos + distFromPos; + } + else if (targeted != null) + distFromPos = (Projectile.Center - targeted.Center); + + + distFromPos += -Projectile.velocity * 3.5f; + Projectile.velocity *= 0.97f + (Projectile.ai[1] * 0.0025f); + } + } + + if (time == startTime) + { + Projectile.timeLeft = (int)(endTime * 2); + move = true; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 15; + } + time++; + } + public override bool ShouldUpdatePosition() => move; + public Color GetRandomColor() + { + Color useColor = Main.rand.Next(4) switch + { + 0 => c1, + 1 => c2, + _ => c3, + }; + return useColor; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D star = Request("CalamityMod/ExtraTextures/SimpleStar").Value; + Texture2D tex = Request("CalamityMod/Particles/CircularSmear").Value; + Texture2D tex2 = Request("CalamityMod/Particles/FadeStreak").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = star.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(tex, drawPosition, null, shiftColor with { A = 0 } * Math.Max((float)Math.Pow(squash, 5) - 0.15f, 0), Projectile.rotation * 1.6f, tex.Size() * 0.5f, Projectile.scale * Owner.gravDir * 0.39f, SpriteEffects.None); + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(star, drawPosition, null, i == 0 ? Color.White with { A = 0 } * 0.3f : (shiftColor with { A = 0 } * 0.6f), Projectile.rotation, rotationPoint, new Vector2(1f * squash, 1f + (1 - squash)) * Projectile.scale * Owner.gravDir * (i == 0 ? 0.12f : 0.2f), SpriteEffects.None); + return false; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float minMult = 0.1f; + int hitsToMinMult = 2; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + } + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 15; i++) + { + float variance = Main.rand.NextFloat(-0.5f, 0.5f); + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle); + dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 1.5f; + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2); + dust.noGravity = true; + dust.color = GetRandomColor(); + dust.fadeIn = 2.5f; + } + } + + } +} diff --git a/Projectiles/Ranged/StarmadaHoldout.cs b/Projectiles/Ranged/StarmadaHoldout.cs new file mode 100644 index 0000000000..dc1155a0e9 --- /dev/null +++ b/Projectiles/Ranged/StarmadaHoldout.cs @@ -0,0 +1,351 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class StarmadaHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ItemType(); + public override Vector2 GunTipPosition => base.GunTipPosition + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * -5; + public override float RecoilResolveSpeed => 0.1f; + public override float MaxOffsetLengthFromArm => 32f; + public override float OffsetXUpwards => -12f; + public override float BaseOffsetY => -10f; + public override float OffsetYDownwards => 10f; + public override float WeaponTurnSpeed => (0.6f); + + public int time = 0; + public int lastUseTime = 0; + public int perfectLeniancy = 2; + public float frontRecoil = 0; + public int goodLeniancy => perfectLeniancy + 6; + public ref float shootingCooldown => ref Projectile.ai[0]; + public ref float starburstTimer => ref Projectile.ai[1]; + public int extendedCooldown => (int)(lastUseTime * 1.2f); + public int naildriverCooldown => (int)(lastUseTime * 1.5f); + public int starburstPerfectTime = 23; + public float recoilIntensity = 0; + public int recoilTimerMax = 62; + public Vector2 recoilDirection; + public bool setVel = true; + public float glowIntensity = 1; + public Color c1 = new Color(164, 47, 160); + public Color c2 = new Color(227, 97, 72); + public Color c3 = new Color(193, 255, 146); + public Color shiftColor; + public ref float starburstCooldown => ref Projectile.ai[2]; + public bool naildriver => ((starburstTimer <= starburstPerfectTime + perfectLeniancy) && (starburstTimer >= starburstPerfectTime - perfectLeniancy)); // if within perfect frame window + public bool scattershot => !naildriver && ((starburstTimer <= starburstPerfectTime + goodLeniancy) && (starburstTimer >= starburstPerfectTime - goodLeniancy)); // If within early or late frame window + public override void KillHoldoutLogic() { } + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.penetrate = -1; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.tileCollide = false; + } + public override void HoldoutAI() + { + float rate = (time * 0.05f); + List eColors = new List() + { + c1, + c2, + c3, + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + SetUsage = false; + bool doingNothing = shootingCooldown == 0 && starburstCooldown == 0 && starburstTimer == 0; + if (lastUseTime == 0 || doingNothing) + lastUseTime = Owner.HeldItem.useAnimation; + if (!doingNothing) + Owner.itemTime = Owner.itemAnimation = 2; + + glowIntensity = MathHelper.Lerp(glowIntensity, (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax, 0, shootingCooldown, true), 5), 0.2f); + frontRecoil = MathHelper.Lerp(frontRecoil, 0, 0.11f); + + if ((Owner.HeldItem.type != ItemType() && doingNothing) || Owner.dead) + { + Projectile.Kill(); + return; + } + bool leftShootChecks = Main.mouseLeft && !Main.mapFullscreen && !Owner.mouseInterface && shootingCooldown == 0; + bool rightShootChecks = Owner.Calamity().mouseRight && !Main.mapFullscreen && !Owner.mouseInterface && starburstCooldown == 0 && starburstTimer == 0; + if (leftShootChecks) + FireShotgun(); + if (rightShootChecks) + { + SoundStyle test = new("CalamityMod/Sounds/Item/StarfleetStarburst"); + SoundEngine.PlaySound(test with { Volume = 1f, Pitch = 0f }, Projectile.Center); + starburstTimer++; + } + if (starburstTimer > 0) + { + // Do wind up animation + if (starburstTimer < starburstPerfectTime / 2) + { + float up = (1 - (float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2 - 1, 0, starburstTimer, true), 2)); + OffsetLengthFromArm = 32 - 7 * up; + frontRecoil = -25 * up; + } + else + { + float down = ((float)Math.Pow(Utils.GetLerpValue(starburstPerfectTime / 2, starburstPerfectTime - 1, starburstTimer, true), 12)); + OffsetLengthFromArm = 25 + 15 * down; + frontRecoil = -25 + 25 * down; + } + + if (starburstTimer == starburstPerfectTime) + FireStarburst(); + + starburstTimer++; + if (starburstTimer > starburstPerfectTime + goodLeniancy + 1) + starburstTimer = 0; + } + if (shootingCooldown > 0) + shootingCooldown--; + if (starburstCooldown > 0) + starburstCooldown--; + if (recoilIntensity > 0 && (shootingCooldown > 0 || starburstCooldown > 0)) + ManageRecoil(); + time++; + } + public void ManageRecoil() + { + float slowdown = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4); + Vector2 movement = recoilDirection * (recoilIntensity) * slowdown; + if (Collision.SolidCollision(Owner.Center + movement, (int)(Owner.width * 1.1f), (int)(Owner.height * 1.1f)) || !Owner.Calamity().mouseRight) + { + recoilIntensity = 0; + return; + } + if (slowdown > 0.1f) + { + if (setVel) + { + Owner.velocity = movement * 0.25f; + setVel = false; + } + Projectile.Center += movement; + Owner.Center += movement; + } + else + setVel = true; + } + public void FireShotgun() + { + // 50% chance to not consume ammo + Owner.PickAmmo(HeldItem, out _, out _, out _, out _, out _, Main.rand.NextBool()); + + SoundStyle shotgunFire = new("CalamityMod/Sounds/Item/StarmadaFire"); + for (int i = 0; i < (naildriver ? 2 : 1); i++) + SoundEngine.PlaySound(shotgunFire with { Volume = 0.7f, Pitch = ((naildriver && i == 0) ? -0.2f : 0f), MaxInstances = 2 }, Projectile.Center); + // Perfects have longer cooldown + int cooldown = (naildriver ? naildriverCooldown : lastUseTime); + recoilTimerMax = cooldown; + shootingCooldown = cooldown; + recoilDirection = -Projectile.velocity; + Owner.Calamity().GeneralScreenShakePower = (naildriver ? 10 : scattershot ? 8 : 5); + OffsetLengthFromArm = (naildriver ? 0 : scattershot ? 7 : 15); + frontRecoil = (naildriver ? -25 : scattershot ? -18 : -10); + + for (int i = 0; i < 8; i++) + { + float randomVel = Main.rand.NextFloat(0.8f, 1f); + float damageMult = (naildriver || scattershot) ? 2f : 1f; + float spread = (naildriver ? 0.06f : scattershot ? 0.9f : 0.25f); + Projectile shotgun = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, randomVel * Projectile.velocity.RotatedByRandom(spread) * 8, ModContent.ProjectileType(), (int)(Projectile.damage * damageMult), Projectile.knockBack, Projectile.owner, 0, 0, Main.rand.Next(0, 300 + 1)); + shotgun.extraUpdates = naildriver ? 9 : scattershot ? 7 : 3; + } + for (int i = 0; i < 25; i++) + { + float variance = Main.rand.NextFloat(-0.7f, 0.7f); + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(GunTipPosition, dustStyle); + dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 3f; + dust.velocity = Projectile.velocity.RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2); + dust.noGravity = true; + dust.color = GetRandomColor(); + dust.fadeIn = 4.75f; + } + + // You can uncomment this to check your timing + /*if (naildriver) + Main.NewText("naildriver: " + (starburstPerfectTime - starburstTimer), Color.DarkOrchid); + if (scattershot) + Main.NewText("scattershot: " + (starburstPerfectTime - starburstTimer), Color.Lime);*/ + + recoilIntensity = (naildriver ? 70f : scattershot ? 25f : 0); + setVel = true; + } + public void FireStarburst() + { + if (Owner.Calamity().GeneralScreenShakePower < 8) + Owner.Calamity().GeneralScreenShakePower = 8; + recoilDirection = -Projectile.velocity; + if (recoilIntensity < 19) + recoilIntensity = 19; + if (recoilTimerMax < extendedCooldown) + recoilTimerMax = extendedCooldown; + if (starburstCooldown < extendedCooldown) + starburstCooldown = extendedCooldown; + setVel = true; + + Vector2 blastCenter = GunTipPosition + Projectile.velocity * 10; + float blastSize = 180; + float minMultiplier = 0.1f; + int hitsToMinMult = 6; + Projectile blast = Projectile.NewProjectileDirect(Owner.GetSource_FromThis(), blastCenter, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 3), -45, Owner.whoAmI, blastSize, minMultiplier, hitsToMinMult); + blast.timeLeft = 15; + + for (int x = 0; x < Main.maxProjectiles; x++) + { + Projectile projectile = Main.projectile[x]; + if (projectile.active && projectile.type == ModContent.ProjectileType() && projectile.localAI[2] == 1) + { + projectile.localAI[2] = 5; + projectile.velocity = projectile.Center.DirectionFrom(Owner.Center) * 12; + projectile.timeLeft = 300; + } + } + + for (int i = 0; i < 20; i++) + { + float dist = Main.rand.NextFloat(1, 4); + Particle forwardJet = new CustomSpark(GunTipPosition + Main.rand.NextVector2CircularEdge(dist * 3.5f, dist * 3.5f), Projectile.velocity * Main.rand.NextFloat(5, 6) * (8 - dist * 2), "CalamityMod/Particles/ForwardSmear", false, (int)(Main.rand.Next(9, 15 + 1) + (dist * 3)), Main.rand.NextFloat(0.15f, 0.25f), GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: 0.3f); + GeneralParticleHandler.SpawnParticle(forwardJet); + } + for (int i = 0; i < 34; i++) + { + float rot = Main.rand.NextFloat(0.05f, 0.35f) * (Main.rand.NextBool() ? -1 : 1); + Vector2 startVel = Projectile.velocity.RotatedBy(rot) * Main.rand.NextFloat(8, 18) * (Main.rand.NextBool(4) ? 2f : 1); + Particle stars = new VelChangingSpark(GunTipPosition, startVel, startVel.RotatedBy(rot * 5), "CalamityMod/Particles/PulseStar", Main.rand.Next(25, 45 + 1), Main.rand.NextFloat(0.1f, 0.35f), GetRandomColor(), new Vector2(1f, 1f), shrinkSpeed: Main.rand.NextFloat(0.02f, 0.06f), lerpRate: 0.02f, glowCenter: true); + GeneralParticleHandler.SpawnParticle(stars); + } + int parts = 85; + for (int i = 0; i < parts; i++) + { + Vector2 intenededVel = (MathHelper.TwoPi * i / parts).ToRotationVector2() * 5f; + Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxVelEnd = new Vector2(intenededVel.X * 0.5f, intenededVel.Y * 6f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxPlace = GunTipPosition + fxVel.RotatedBy(Projectile.velocity.ToRotation()); + + float size = Utils.GetLerpValue(0, -5, intenededVel.X, true); + float width = Utils.GetLerpValue(0, 5 * Math.Sign(fxVel.X), fxVel.X, true); + Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f)); + + Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(19 + size * 6), 0.45f + size * 0.23f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f); + GeneralParticleHandler.SpawnParticle(aura); + + } + int parts2 = 45; + for (int i = 0; i < parts2; i++) + { + Vector2 intenededVel = (MathHelper.TwoPi * i / parts2).ToRotationVector2() * 3f; + Vector2 fxVel = new Vector2(intenededVel.X, intenededVel.Y * 2.3f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxVelEnd = new Vector2(intenededVel.X * 0.5f, intenededVel.Y * 6f).RotatedBy(Projectile.velocity.ToRotation()); + Vector2 fxPlace = GunTipPosition + Projectile.velocity * 45 + fxVel.RotatedBy(Projectile.velocity.ToRotation()); + + float size = Utils.GetLerpValue(0, -3, intenededVel.X, true); + float width = Utils.GetLerpValue(0, 3 * Math.Sign(fxVel.X), fxVel.X, true); + Color clr = (size <= 0.5f ? Color.Lerp(c3, c2, size * 2) : Color.Lerp(c2, c1, size * 2 - 1f)); + + Particle aura = new CustomSpark(fxPlace, fxVel * 1.2f, "CalamityMod/Particles/BloomCircle", false, (int)(15 + size * 5), 0.35f + size * 0.2f, clr * 0.7f, new Vector2(1f + width * size, 1f), glowCenter: true, glowOpacity: size * 0.85f, glowCenterScale: 0.75f); + GeneralParticleHandler.SpawnParticle(aura); + + } + } + public Color GetRandomColor() + { + Color useColor = Main.rand.Next(4) switch + { + 0 => c1, + 1 => c2, + _ => c3, + }; + return useColor; + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + return false; + Texture2D orb = Request("CalamityMod/Particles/BloomCircle").Value; + + Texture2D front = Request("CalamityMod/Projectiles/Ranged/StarmadaFront").Value; + Texture2D frontGlow = Request("CalamityMod/Projectiles/Ranged/StarmadaFrontGlow").Value; + Texture2D back = Request("CalamityMod/Projectiles/Ranged/StarmadaBack").Value; + Texture2D backGlow = Request("CalamityMod/Projectiles/Ranged/StarmadaBackGlow").Value; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + float glowMult = (float)Math.Pow(Utils.GetLerpValue(recoilTimerMax / 2, recoilTimerMax, Math.Max(shootingCooldown, starburstCooldown), true), 4); + int draws = 18; + float sine = (float)Math.Sin(time * 0.02f); + float attackMult = (float)Math.Pow(Utils.GetLerpValue(0, starburstPerfectTime - 1, starburstTimer, true), 2); + float sine2 = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 55.5f / MathHelper.Pi); + float fastSine = (float)Math.Sin(time * 0.2f); + Color glowColor = shiftColor; + Vector2 frontRecoilPlace = Projectile.velocity * frontRecoil; + + if (starburstTimer > 0 && starburstCooldown == 0) + { + for (int i = 0; i < draws; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time * 2); + Main.EntitySpriteDraw(back, drawPosition + drawOffset * 6 * attackMult, null, shiftColor with { A = 0 } * 0.7f * attackMult, drawRotation, back.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(front, drawPosition + drawOffset * 6 * attackMult + frontRecoilPlace, null, shiftColor with { A = 0 } * 0.7f * attackMult, drawRotation, front.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + } + } + + // back + Main.EntitySpriteDraw(back, drawPosition, null, drawColor, drawRotation, back.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + for (int i = 0; i < draws; i++) // back glow + { + Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time / 5) * (1.25f + (fastSine + 2f) * 0.2f + glowMult * 4); + Main.EntitySpriteDraw(backGlow, drawPosition + drawOffset, null, Color.Lerp(Color.Gray * 0.15f, glowColor with { A = 0 }, glowIntensity) * (0.1f + 0.5f * glowMult), drawRotation, backGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(backGlow, drawPosition, null, Color.Lerp(Color.Gray * 0.15f, Color.White with { A = 0 }, glowIntensity), drawRotation, backGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + } + // front + Main.EntitySpriteDraw(front, drawPosition + frontRecoilPlace, null, drawColor, drawRotation, front.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + for (int i = 0; i < draws; i++) // front glow + { + Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time / 5) * (1.25f + (fastSine + 2f) * 0.2f + glowMult * 4); + Main.EntitySpriteDraw(frontGlow, drawPosition + drawOffset + frontRecoilPlace, null, Color.Lerp(Color.Gray * 0.15f, glowColor with { A = 0 }, glowIntensity) * (0.1f + 0.5f * glowMult), drawRotation, frontGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(frontGlow, drawPosition + frontRecoilPlace, null, Color.Lerp(Color.Gray * 0.15f, Color.White with { A = 0 }, glowIntensity), drawRotation, frontGlow.Size() * 0.5f, Projectile.scale * Owner.gravDir, flipSprite); + } + + if (starburstTimer > 0 && starburstCooldown == 0) + { + for (int i = 0; i < 6; i++) + { + // The shining orb at the tip + Color orbColor = shiftColor with { A = 0 } * 0.5f; + Vector2 scale = new Vector2(Math.Abs(sine2 * 0.5f) + 0.1f, 1) * (0.05f + i * 0.01f) * attackMult * Main.rand.NextFloat(0.9f, 1.1f) * 8.5f; + Main.EntitySpriteDraw(orb, GunTipPosition - Main.screenPosition, null, orbColor, Main.rand.NextFloat(-5, 5), orb.Size() * 0.5f, scale, SpriteEffects.None); + } + } + + return false; + } + } +} diff --git a/Projectiles/Ranged/StarmadaStar.cs b/Projectiles/Ranged/StarmadaStar.cs new file mode 100644 index 0000000000..223378eddc --- /dev/null +++ b/Projectiles/Ranged/StarmadaStar.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class StarmadaStar : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public Color c1 = new Color(164, 47, 160); + public Color c2 = new Color(227, 97, 72); + public Color c3 = new Color(193, 255, 146); + public Color shiftColor; + public Player Owner => Main.player[Projectile.owner]; + public override void SetDefaults() + { + Projectile.width = 25; + Projectile.height = 25; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 1; + Projectile.penetrate = 5; + Projectile.timeLeft = 600; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = false; + } + + public override void AI() + { + float rate = (Projectile.ai[2] * 0.05f); + List eColors = new List() + { + c1, + c2, + c3, + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + shiftColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + Projectile.ai[2]++; + + if (time > 5 && time % 2 == 0) + { + Particle trail = new CustomSpark(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 28, Projectile.velocity, "CalamityMod/Particles/DualTrail", false, 15, 0.11f, shiftColor, new Vector2(0.9f, 1.1f), shrinkSpeed: 0.5f); + GeneralParticleHandler.SpawnParticle(trail); + + if (time > 18) + { + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), dustStyle); + dust.scale = Main.rand.NextFloat(1.2f, 1.8f); + dust.velocity = -Projectile.velocity * Main.rand.NextFloat(3f, 5f); + dust.noGravity = true; + dust.color = shiftColor; + dust.fadeIn = 5f; + } + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + time++; + } + public Color GetRandomColor() + { + Color useColor = Main.rand.Next(4) switch + { + 0 => c1, + 1 => c2, + _ => c3, + }; + return useColor; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex2 = Request("CalamityMod/Particles/FadeStreak").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + for (int i = 0; i < 5; i++) + { + Vector2 offset = (MathHelper.TwoPi * i / 5).ToRotationVector2().RotatedBy(Projectile.rotation + MathHelper.Pi); + for (int t = 0; t < 3; t++) + Main.EntitySpriteDraw(tex2, drawPosition, null, shiftColor with { A = 0 }, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2((2.3f + t * 0.03f) * (i == 2 ? 1.8f : i == 3 ? 1.8f : 1), (1.1f + t * 0.03f) * (i == 2 ? 0.75f : i == 3 ? 0.75f : 1)) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically); + Main.EntitySpriteDraw(tex2, drawPosition, null, Color.White with { A = 0 }, offset.ToRotation(), new Vector2(tex2.Width * 0.5f, 0), new Vector2(1.5f, 0.7f) * Projectile.scale * Owner.gravDir * 0.3f, SpriteEffects.FlipVertically); + } + return false; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float minMult = 0.1f; + int hitsToMinMult = 4; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + + if (Projectile.numHits == 0) + { + // spawn slice projectiles + Vector2 spawnPos = target.Center + Vector2.UnitY.RotatedByRandom(0.6f) * (target.height / 2 + 40); + Vector2 vel = spawnPos.DirectionTo(target.Center); + int damage = (int)(Projectile.damage * 0.33f); + Projectile shotgun = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), spawnPos, vel, ModContent.ProjectileType(), damage, 0, Projectile.owner, target.whoAmI, Main.rand.Next(0, 7 + 1), Main.rand.Next(0, 300 + 1)); + } + } + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 15; i++) + { + float variance = Main.rand.NextFloat(-0.5f, 0.5f); + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustStyle); + dust.scale = (Main.rand.NextFloat(1.4f, 1.8f) - Math.Abs(variance)) * 1.5f; + dust.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(variance) * Main.rand.NextFloat(18f, 19f) * (float)Math.Pow(1 - Math.Abs(variance), 2); + dust.noGravity = true; + dust.color = GetRandomColor(); + dust.fadeIn = 2.5f; + } + } + + } +} diff --git a/Sounds/Item/StarfleetFire.ogg b/Sounds/Item/StarfleetFire.ogg index 646a299d9a..7c44495a39 100644 Binary files a/Sounds/Item/StarfleetFire.ogg and b/Sounds/Item/StarfleetFire.ogg differ