diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index db8f69a48c..707ba1b9bd 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -61,6 +61,7 @@ using CalamityMod.Particles; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Pets; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; @@ -197,6 +198,11 @@ namespace CalamityMod.CalPlayer if (Player.ActiveItem().type != ModContent.ItemType()) saharaSlicersBolts = 0; + if (Player.whoAmI == Main.myPlayer && Player.HeldItem.type == ModContent.ItemType() && Player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) + { + 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()) heldGaelsLastFrame = true; diff --git a/Graphics/Metaballs/StarsmokeBlueLayer.png b/Graphics/Metaballs/StarsmokeBlueLayer.png new file mode 100644 index 0000000000..77691f5acd Binary files /dev/null and b/Graphics/Metaballs/StarsmokeBlueLayer.png differ diff --git a/Graphics/Metaballs/StarsmokeLayer.png b/Graphics/Metaballs/StarsmokeLayer.png new file mode 100644 index 0000000000..8b14723cbc Binary files /dev/null and b/Graphics/Metaballs/StarsmokeLayer.png differ diff --git a/Graphics/Metaballs/StarsmokeMetaball.cs b/Graphics/Metaballs/StarsmokeMetaball.cs new file mode 100644 index 0000000000..287b691f89 --- /dev/null +++ b/Graphics/Metaballs/StarsmokeMetaball.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class StarsmokeMetaball : Metaball + { + public Color borderColor = Color.Purple; + public Vector2 goalDir = Vector2.Zero; + public Vector2 scrollDir = Vector2.Zero; + public class StarsmokeParticle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + public Vector2 BaseSquash = Vector2.One; + public float Rotation; + public float ShrinkSpeed = 0; + public int Lifetime; + public float SquashPower = 0; + public int time = 0; + + public StarsmokeParticle(Vector2 center, Vector2 velocity, float size, int lifetime, Vector2 squash, float shrinkSpeed = 0, float velocitySquash = 0) + { + Center = center; + Velocity = velocity; + Size = size; + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + BaseSquash = squash; + Lifetime = lifetime; + ShrinkSpeed = shrinkSpeed; + SquashPower = velocitySquash; + } + + public void Update() + { + Center += Velocity; + Velocity *= 0.95f; + if ((float)time / (float)Lifetime > 0.5f) + { + Size *= 0.94f; + } + BaseSquash.X *= (1 - 0.2f * ShrinkSpeed); + BaseSquash.Y *= (1 + 0.2f * ShrinkSpeed); + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + time++; + } + } + public static Asset LayerAsset + { + get; + private set; + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeNPCs; + public override void Load() + { + if (Main.dedServ) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/StarsmokeBlueLayer", AssetRequestMode.ImmediateLoad); + } + + public override void Update() + { + if (goalDir == Vector2.Zero) + goalDir = Vector2.One.RotatedByRandom(Math.PI); + if ((int)(Main.GlobalTimeWrappedHourly * 50) % 5 == 0) + { + goalDir = goalDir.RotatedByRandom(0.13f); + } + scrollDir = Vector2.Lerp(scrollDir, goalDir, 0.01f); + + float rate = Main.GlobalTimeWrappedHourly * 19; + List colors = new List() + { + Color.Purple, + Color.BlueViolet, + Color.DarkViolet + }; + + int colorIndex = (int)(rate / 2 % colors.Count); + Color currentColor = colors[colorIndex]; + Color nextColor = colors[(colorIndex + 1) % colors.Count]; + borderColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + public override Color EdgeColor => borderColor with { A = 0 }; + + public static void SpawnParticle(Vector2 position, Vector2 velocity, float size, int lifetime, Vector2 squash, float shrinkSpeed = 0, float velocitySquash = 0) => + Particles.Add(new(position, velocity, size, lifetime, squash, shrinkSpeed, velocitySquash)); + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return scrollDir * 0.5f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/StarsmokeMetaball1").Value; + + foreach (StarsmokeParticle particle in Particles) + { + Vector2 squash = Vector2.Lerp(particle.BaseSquash, new Vector2(Utils.Remap(particle.Velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(particle.Velocity.Length(), 2, 7, 1, 2.5f)), particle.SquashPower); + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, particle.Rotation, origin, squash * scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/StarsmokeMetaball1.png b/Graphics/Metaballs/StarsmokeMetaball1.png new file mode 100644 index 0000000000..522a9295d6 Binary files /dev/null and b/Graphics/Metaballs/StarsmokeMetaball1.png differ diff --git a/Items/Weapons/Ranged/Starfleet.cs b/Items/Weapons/Ranged/Starfleet.cs index 48e4980900..ffd51f4205 100644 --- a/Items/Weapons/Ranged/Starfleet.cs +++ b/Items/Weapons/Ranged/Starfleet.cs @@ -19,43 +19,29 @@ namespace CalamityMod.Items.Weapons.Ranged Item.height = 36; Item.damage = 115; Item.DamageType = DamageClass.Ranged; - Item.useTime = 55; - Item.useAnimation = 55; + Item.useTime = 70; + Item.useAnimation = 70; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 15f; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item92; + Item.channel = true; + Item.noUseGraphic = true; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; Item.useAmmo = AmmoID.FallenStar; } - - public override Vector2? HoldoutOffset() - { - return new Vector2(-8, -11); - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - for (int index = 0; index < 5; ++index) - { - float SpeedX = velocity.X + Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-40, 41) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); - } - return false; - } - + // Holdout projectile is spawned when holding the item, so using the item does nothing + public override bool CanUseItem(Player player) => false; public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.SuperStarCannon). - AddIngredient(6). + AddIngredient(). AddIngredient(4). - AddIngredient(12). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Weapons/Ranged/StarfleetGlow.png b/Items/Weapons/Ranged/StarfleetGlow.png new file mode 100644 index 0000000000..e71cbadefa Binary files /dev/null and b/Items/Weapons/Ranged/StarfleetGlow.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson index b30eecd5a4..c3a3783cdf 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson @@ -3949,8 +3949,8 @@ PolypSand: { } TableCoralLeft: { - DisplayName: Table Coral - Tooltip: "" + DisplayName: Table Coral + Tooltip: "" } VolcanicSand: { diff --git a/Particles/PulseStar.cs b/Particles/PulseStar.cs new file mode 100644 index 0000000000..60fad39360 --- /dev/null +++ b/Particles/PulseStar.cs @@ -0,0 +1,110 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class PulseStar : Particle + { + public Color InitialColor; + public Color EndColor; + public bool AffectedByGravity; + public bool FadeIn = false; + public float FadeInScale = 0f; + public bool GlowCenter = false; + public float GlowCenterScale = 1; + public float GlowOpacity = 1; + public float ExtraRotation; + public Vector2 Stretch = new Vector2(0.5f, 1.6f); + public float ShrinkSpeed = 0; + public bool NoShrink = false; + public float Spin = 0; + public override string Texture => "CalamityMod/Particles/PulseStar"; + public bool AltVisual = true; + public override bool UseAdditiveBlend => AltVisual; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + + public PulseStar(Vector2 relativePosition, Vector2 velocity, string texture, bool affectedByGravity, int lifetime, float scale, Color color, Color endColor, Vector2 stretch, bool useAddativeBlend = true, bool glowCenter = false, float extraRotation = 0, bool fadeIn = false, bool affectedByLight = false, float shrinkSpeed = 0, float glowCenterScale = 1, float glowOpacity = 1, bool flipHorizontal = false, bool noShrink = false, float spin = 0) + { + Position = relativePosition; + Velocity = velocity; + ExtraRotation = extraRotation; + AffectedByGravity = affectedByGravity; + AffectedByLight = affectedByLight; + Scale = scale; + Stretch = stretch; + FadeInScale = scale; + Lifetime = lifetime; + Color = InitialColor = color; + EndColor = endColor; + ShrinkSpeed = shrinkSpeed; + + AltVisual = useAddativeBlend; + GlowCenter = glowCenter; + GlowCenterScale = glowCenterScale; + GlowOpacity = glowOpacity; + NoShrink = noShrink; + + FadeIn = fadeIn; + + if (FadeIn) + Scale = 0f; + Spin = spin; + } + + public override void Update() + { + if (!FadeIn) + { + if (!NoShrink) + Scale *= 0.95f; + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + InitialColor = Color.Lerp(InitialColor, EndColor, LifetimeCompletion); + } + else + { + if ((float)Time / (float)Lifetime < 0.5f) + { + Scale = MathHelper.Lerp(Scale, FadeInScale, 0.2f); + } + else + { + Scale = MathHelper.Lerp(Scale, FadeInScale, -0.21f); + } + } + Velocity *= 0.95f; + if (Velocity.Length() < 12f && AffectedByGravity) + { + Velocity.X *= 0.94f; + Velocity.Y += 0.25f; + } + ExtraRotation += Spin; + Rotation = Velocity.ToRotation() + MathHelper.PiOver2 + ExtraRotation; + + Stretch.X *= (1 - 0.2f * ShrinkSpeed); + Stretch.Y *= (1 + 0.2f * ShrinkSpeed); + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Vector2 scale = Stretch * Scale; + Texture2D texture = ModContent.Request(Texture).Value; + float scaleMult = 1; + Color col = Color; + Color endCol = Color; + + if (AffectedByLight) + { + col = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGB(Color); + endCol = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGB(Color); + } + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(col, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)), Rotation, texture.Size() * 0.5f, scale * scaleMult, SpriteEffects.None, 0f); + if (GlowCenter) + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color.Lerp(Color.Lerp(col, Color.White, 0.8f), Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)) * GlowOpacity, Rotation, texture.Size() * 0.5f, scale * 0.8f * GlowCenterScale * scaleMult, SpriteEffects.None, 0); + } + } +} diff --git a/Particles/PulseStar.png b/Particles/PulseStar.png new file mode 100644 index 0000000000..4505d12981 Binary files /dev/null and b/Particles/PulseStar.png differ diff --git a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs index 7f3e4dea90..c25d7d9345 100644 --- a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs @@ -216,7 +216,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles Owner.ChangeDir(direction); Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = Owner.itemAnimation = 2; + //Owner.itemTime = Owner.itemAnimation = 2; Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); // -Pi/2 because the arms rotation starts with arms pointing down. diff --git a/Projectiles/Ranged/PlasmaBlast.cs b/Projectiles/Ranged/PlasmaBlast.cs index af1049f2ba..b289c8a458 100644 --- a/Projectiles/Ranged/PlasmaBlast.cs +++ b/Projectiles/Ranged/PlasmaBlast.cs @@ -1,4 +1,8 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Projectiles.DraedonsArsenal; +using Microsoft.Build.Construction; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -20,7 +24,6 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.width = 10; Projectile.height = 10; - Projectile.alpha = 150; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.extraUpdates = 1; @@ -31,84 +34,32 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { - if (Projectile.soundDelay == 0) - { - Projectile.soundDelay = 20 + Main.rand.Next(40); - SoundEngine.PlaySound(SoundID.Item9, Projectile.position); - } - - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] == 12f) - { - Projectile.localAI[0] = 0f; - for (int l = 0; l < 12; l++) - { - Vector2 dustVel = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - dustVel += -Vector2.UnitY.RotatedBy((double)((float)l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); - dustVel = dustVel.RotatedBy((double)(Projectile.rotation - MathHelper.PiOver2), default); - int dust = Dust.NewDust(Projectile.Center, 0, 0, DustID.FireworkFountain_Blue, 0f, 0f, 160, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].position = Projectile.Center + dustVel; - Main.dust[dust].velocity = Projectile.velocity * 0.1f; - Main.dust[dust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[dust].position) * 1.25f; - } - } - - Projectile.alpha -= 15; - int alphaControl = 150; - if (Projectile.Center.Y >= Projectile.ai[1]) - alphaControl = 0; - if (Projectile.alpha < alphaControl) - Projectile.alpha = alphaControl; - - Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; - - if (Main.rand.NextBool(16)) - { - Vector2 extraDustVel = Vector2.UnitX.RotatedByRandom(MathHelper.PiOver2).RotatedBy((double)Projectile.velocity.ToRotation(), default); - int extraDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.FireworkFountain_Blue, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f); - Main.dust[extraDust].velocity = extraDustVel * 0.66f; - Main.dust[extraDust].position = Projectile.Center + extraDustVel * 12f; - } - - if (Main.rand.NextBool(48) && !Main.dedServ) - { - int gore = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); - Main.gore[gore].velocity *= 0.66f; - Main.gore[gore].velocity += Projectile.velocity * 0.3f; - } - - if (Projectile.ai[1] == 1f) - { - Projectile.light = 0.9f; - if (Main.rand.NextBool(10)) - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.FireworkFountain_Blue, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1f); - if (Main.rand.NextBool(20) && !Main.dedServ) - Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.position, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f); - } - - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.1f / 255f, (255 - Projectile.alpha) * 0.7f / 255f, (255 - Projectile.alpha) * 0.15f / 255f); + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; } - public override bool PreDraw(ref Color lightColor) { CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + //Vector2 launchVel = Projectile.velocity.SafeNormalize(Vector2.UnitX); + //float launchPower = (Projectile.ai[2] == 5 ? 35 : 14); + //target.MoveNPC(launchVel, launchPower, true); + + float minMult = 0.3f; + int hitsToMinMult = 7; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 180); + } - public override void OnKill(int timeLeft) { - if (Projectile.ai[0] == 1f) - return; - - if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - - SoundEngine.PlaySound(SoundID.Item10, Projectile.position); + } + } } diff --git a/Projectiles/Ranged/StarfleetHoldout.cs b/Projectiles/Ranged/StarfleetHoldout.cs new file mode 100644 index 0000000000..5f25597cfc --- /dev/null +++ b/Projectiles/Ranged/StarfleetHoldout.cs @@ -0,0 +1,177 @@ +using System; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Rogue; +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 StarfleetHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ItemType(); + public override Vector2 GunTipPosition => base.GunTipPosition; + public override float RecoilResolveSpeed => 0.1f; + public override float MaxOffsetLengthFromArm => 25f; + public override float OffsetXUpwards => -12f; + public override float BaseOffsetY => -10f; + public override float OffsetYDownwards => 10f; + public override float WeaponTurnSpeed => (0.6f); + + public int lastUseTime = 0; + public int perfectLeniancy = 2; + public int time = 0; + public int goodLeniancy => perfectLeniancy + 9; + 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 = 0; + public Vector2 recoilDirection; + public bool setVel = true; + 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 HoldoutAI() + { + bool doingNothing = shootingCooldown == 0 && starburstCooldown == 0 && starburstTimer == 0; + if (lastUseTime == 0 || doingNothing) + lastUseTime = Owner.HeldItem.useAnimation; + if (!doingNothing) + Owner.itemTime = Owner.itemAnimation = 2; + + if (Owner.HeldItem.type != ItemType() && doingNothing) + { + 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) + 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))) + { + 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"); + SoundEngine.PlaySound(shotgunFire with { Volume = 1f, Pitch = 0f }, Projectile.Center); + // Perfects have longer cooldown + int cooldown = (naildriver ? naildriverCooldown : lastUseTime); + recoilTimerMax = cooldown; + shootingCooldown = cooldown; + recoilDirection = -Projectile.velocity; + Owner.Calamity().GeneralScreenShakePower = (naildriver ? 9 : scattershot ? 7 : 4); + OffsetLengthFromArm = (naildriver ? 0 : scattershot ? 7 : 15); + + for (int i = 0; i < 12; i++) + { + float randomVel = Main.rand.NextFloat(0.7f, 1.1f); + float damageMult = (naildriver || scattershot) ? 1.5f : 1f; + Projectile shotgun = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, randomVel * Projectile.velocity.RotatedByRandom(naildriver ? 0.1f : scattershot ? 0.9f : 0.35f) * ((naildriver || scattershot) ? 8 : 6), ModContent.ProjectileType(), (int)(Projectile.damage * damageMult), Projectile.knockBack, Projectile.owner); + shotgun.extraUpdates = naildriver ? 6 : scattershot ? 4 : 2; + } + if (naildriver) + Main.NewText("naildriver"); + if (scattershot) + Main.NewText("scattershot"); + recoilIntensity = (naildriver ? 75f : scattershot ? 50f : 10f); + } + public void FireStarburst() + { + if (Owner.Calamity().GeneralScreenShakePower < 7) + Owner.Calamity().GeneralScreenShakePower = 7; + if (OffsetLengthFromArm > 10) + OffsetLengthFromArm = 10; + recoilDirection = -Projectile.velocity; + if (recoilIntensity < 25) + recoilIntensity = 25; + if (recoilTimerMax < extendedCooldown) + recoilTimerMax = extendedCooldown; + if (starburstCooldown < extendedCooldown) + starburstCooldown = extendedCooldown; + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Vector2.Zero, ModContent.ProjectileType(), 0, Projectile.knockBack, Projectile.owner); + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + return false; + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Texture2D glowTexture = Request("CalamityMod/Items/Weapons/Ranged/StarfleetGlow").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + 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 fastSine = (float)Math.Sin(time * 0.2f); + Color glowColor = Color.Lerp(Color.White, Color.Cyan, 1 + sine); + for (int i = 0; i < draws; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / draws).ToRotationVector2().RotatedBy(time / 5) * (1.25f + (fastSine + 2f) * 0.2f + glowMult * 4); + Main.EntitySpriteDraw(glowTexture, drawPosition + drawOffset, null, glowColor with { A = 0 } * (0.1f + 0.5f * glowMult), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(glowTexture, drawPosition, null, Color.White with { A = 0 }, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + } + + return false; + } + } +} diff --git a/Projectiles/Ranged/StarmageddonStar.cs b/Projectiles/Ranged/StarmageddonStar.cs index 207cf9d1f4..62830b8be3 100644 --- a/Projectiles/Ranged/StarmageddonStar.cs +++ b/Projectiles/Ranged/StarmageddonStar.cs @@ -136,7 +136,6 @@ namespace CalamityMod.Projectiles.Ranged int type = Utils.SelectRandom(Main.rand, [ - ModContent.ProjectileType(), ModContent.ProjectileType(), ProjectileID.StarCannonStar, ProjectileID.Starfury diff --git a/Sounds/Item/StarfleetFire.ogg b/Sounds/Item/StarfleetFire.ogg new file mode 100644 index 0000000000..646a299d9a Binary files /dev/null and b/Sounds/Item/StarfleetFire.ogg differ diff --git a/Sounds/Item/StarfleetStarburst.ogg b/Sounds/Item/StarfleetStarburst.ogg new file mode 100644 index 0000000000..71e89d12eb Binary files /dev/null and b/Sounds/Item/StarfleetStarburst.ogg differ diff --git a/Sounds/Item/StarmadaFire.ogg b/Sounds/Item/StarmadaFire.ogg new file mode 100644 index 0000000000..32a54102f8 Binary files /dev/null and b/Sounds/Item/StarmadaFire.ogg differ diff --git a/en-US.hjson b/en-US.hjson new file mode 100644 index 0000000000..ef39b04362 --- /dev/null +++ b/en-US.hjson @@ -0,0 +1,10 @@ +Mods: { + CalamityMod: { + Items: { + TableCoralLeft: { + DisplayName: Table Coral Left + Tooltip: "" + } + } + } +}