diff --git a/Items/Weapons/Melee/Cnidarian.cs b/Items/Weapons/Melee/Cnidarian.cs index 5340450ce7..92d09cdcae 100644 --- a/Items/Weapons/Melee/Cnidarian.cs +++ b/Items/Weapons/Melee/Cnidarian.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee DisplayName.SetDefault("Cnidarian"); Tooltip.SetDefault("Fishes up an electric jellyfish\n" + "Periodically sends out sparks to electrocute nearby enemies."); + //Tooltip could include a lore line about electric attributes that are shared in sunken sealife SacrificeTotal = 1; } @@ -70,7 +71,7 @@ namespace CalamityMod.Items.Weapons.Melee public void SetItemInHand(Player player, Rectangle heldItemFrame) { //Make the player face where they're aiming. - if (Main.MouseWorld.X > player.Center.X) + if (player.Calamity().mouseWorld.X > player.Center.X) { player.ChangeDir(1); } @@ -86,7 +87,7 @@ namespace CalamityMod.Items.Weapons.Melee public void SetPlayerArms(Player player) { //Calculate the dirction in which the players arms should be pointing at. - Vector2 playerToCursor = (Main.MouseWorld - player.Center).SafeNormalize(Vector2.UnitX); + Vector2 playerToCursor = (player.Calamity().mouseWorld - player.Center).SafeNormalize(Vector2.UnitX); float armPointingDirection = (playerToCursor.ToRotation()); diff --git a/Items/Weapons/Ranged/ReedBlowgun.cs b/Items/Weapons/Ranged/ReedBlowgun.cs index cdf36a6233..106e0f162a 100644 --- a/Items/Weapons/Ranged/ReedBlowgun.cs +++ b/Items/Weapons/Ranged/ReedBlowgun.cs @@ -5,15 +5,18 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Audio; namespace CalamityMod.Items.Weapons.Ranged { public class ReedBlowgun : ModItem { + public static readonly SoundStyle BubbleBurstSound = new ("CalamityMod/Sounds/Custom/PistolShrimpBubbleBurst") { PitchVariance = 0.15f, Volume = 0.2f}; + public override void SetStaticDefaults() { DisplayName.SetDefault("Reed Blowgun"); - Tooltip.SetDefault("Fires slow-moving water blasts"); + Tooltip.SetDefault("Fires a high-pressure stream of bubbles"); SacrificeTotal = 1; } @@ -26,24 +29,90 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useTime = 25; Item.useAnimation = 25; Item.useStyle = ItemUseStyleID.Shoot; + Item.holdStyle = 16; Item.noMelee = true; - Item.knockBack = 2.5f; + Item.knockBack = 13.5f; Item.value = Item.buyPrice(0, 2, 0, 0); Item.rare = ItemRarityID.Green; - Item.UseSound = SoundID.Item5; + Item.UseSound = null; Item.autoReuse = true; - Item.shoot = ProjectileID.PurificationPowder; + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; - Item.useAmmo = AmmoID.Arrow; Item.Calamity().canFirePointBlankShots = true; } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + public override void HoldItem(Player player) { - float SpeedX = velocity.X + (float)Main.rand.Next(-30, 31) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-30, 31) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX * 0.5f, SpeedY * 0.5f, ModContent.ProjectileType(), (int)(damage * 0.4), 0f, player.whoAmI); - return true; + player.Calamity().mouseWorldListener = true; + } + + public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) + { + velocity = velocity.RotatedByRandom(0.01f); + } + + public void SetItemInHand(Player player, Rectangle heldItemFrame) + { + //Make the player face where they're aiming. + if (Main.MouseWorld.X > player.Center.X) + { + player.ChangeDir(1); + } + else + { + player.ChangeDir(-1); + } + + float blowpipeRotation = player.compositeBackArm.rotation + MathHelper.PiOver2 + player.direction * MathHelper.PiOver4 / 3f; + + Vector2 blowpipePosition = player.GetBackHandPosition(player.compositeBackArm.stretch, player.compositeBackArm.rotation).Floor() + Vector2.UnitY * 7f; + if (player.direction > 0) + blowpipePosition += Vector2.UnitX * -9f; + + CalamityUtils.CleanHoldStyle(player, blowpipeRotation, blowpipePosition, new Vector2(50, 18), new Vector2(-17, 6)); + } + + + public void SetPlayerArms(Player player, bool frontArm = false) + { + //Make the player face where they're aiming. + if (player.Calamity().mouseWorld.X > player.Center.X) + { + player.ChangeDir(1); + } + else + { + player.ChangeDir(-1); + } + + //Calculate the dirction in which the players arms should be pointing at. + Vector2 playerToCursor = (player.Calamity().mouseWorld - player.Center).SafeNormalize(Vector2.UnitX); + float pointingDirection = (playerToCursor.ToRotation()); + + if (frontArm) + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, pointingDirection - MathHelper.PiOver2); + player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, pointingDirection - MathHelper.PiOver2); + player.headRotation = pointingDirection; + } + + public override void HoldStyle(Player player, Rectangle heldItemFrame) + { + SetItemInHand(player, heldItemFrame); + } + + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + SetItemInHand(player, heldItemFrame); + } + + public override void HoldItemFrame(Player player) + { + SetPlayerArms(player); + } + + public override void UseItemFrame(Player player) + { + SetPlayerArms(player, true); } public override void AddRecipes() diff --git a/Particles/Bubble.png b/Particles/Bubble.png new file mode 100644 index 0000000000..b804a98405 Binary files /dev/null and b/Particles/Bubble.png differ diff --git a/Particles/DirectionalPulseRing.cs b/Particles/DirectionalPulseRing.cs new file mode 100644 index 0000000000..5e22c895b4 --- /dev/null +++ b/Particles/DirectionalPulseRing.cs @@ -0,0 +1,55 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using static CalamityMod.CalamityUtils; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class DirectionalPulseRing : Particle + { + public override string Texture => "CalamityMod/Particles/HollowCircleHardEdge"; + public override bool UseAdditiveBlend => true; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + + private float OriginalScale; + private float FinalScale; + private float opacity; + private Vector2 Squish; + private Color BaseColor; + + public DirectionalPulseRing(Vector2 position, Vector2 velocity, Color color, Vector2 squish, float rotation, float originalScale, float finalScale, int lifeTime) + { + Position = position; + Velocity = velocity; + BaseColor = color; + OriginalScale = originalScale; + FinalScale = finalScale; + Scale = originalScale; + Lifetime = lifeTime; + Squish = squish; + Rotation = rotation; + } + + public override void Update() + { + float pulseProgress = PiecewiseAnimation(LifetimeCompletion, new CurveSegment[] { new CurveSegment(EasingType.PolyOut, 0f, 0f, 1f, 4) }); + Scale = MathHelper.Lerp(OriginalScale, FinalScale, pulseProgress); + + opacity = (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2); + + Color = BaseColor * opacity; + Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); + Velocity *= 0.95f; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale * Squish, SpriteEffects.None, 0); + } + + } +} diff --git a/Particles/GenericBubbleParticle.cs b/Particles/GenericBubbleParticle.cs new file mode 100644 index 0000000000..b20f7cafa4 --- /dev/null +++ b/Particles/GenericBubbleParticle.cs @@ -0,0 +1,25 @@ +using Microsoft.Xna.Framework; +using Terraria; + + +namespace CalamityMod.Particles +{ + //This is mostly so i can easily get it to draw over the reed blowgun. + public class GenericBubbleParticle : Particle + { + public override string Texture => "CalamityMod/Particles/Bubble"; + public override bool UseHalfTransparency => true; + public override bool SetLifetime => true; + public override bool Important => true; + + public GenericBubbleParticle(Vector2 position, Vector2 velocity, float scale, float rotation, int lifeTime = 50) + { + Position = position; + Velocity = velocity; + Color = Color.White; + Scale = scale; + Rotation = rotation; + Lifetime = lifeTime; + } + } +} diff --git a/Projectiles/Melee/CnidarianJellyfishOnTheString.cs b/Projectiles/Melee/CnidarianJellyfishOnTheString.cs index 0ba6a93377..b44de1fd36 100644 --- a/Projectiles/Melee/CnidarianJellyfishOnTheString.cs +++ b/Projectiles/Melee/CnidarianJellyfishOnTheString.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Melee //Sounds public static readonly SoundStyle ZapSound = SoundID.Item94 with { Volume = SoundID.Item94.Volume * 0.5f }; - public static readonly SoundStyle SlapSound = new SoundStyle( "CalamityMod/Sounds/Custom/WetSlap", 4 ); + public static readonly SoundStyle SlapSound = new("CalamityMod/Sounds/Custom/WetSlap", 4); internal PrimitiveTrail TrailRenderer; diff --git a/Projectiles/Ranged/PressurizedBubbleStream.cs b/Projectiles/Ranged/PressurizedBubbleStream.cs new file mode 100644 index 0000000000..caf96df793 --- /dev/null +++ b/Projectiles/Ranged/PressurizedBubbleStream.cs @@ -0,0 +1,152 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Audio; +using CalamityMod.Particles; +using CalamityMod.Items.Weapons.Ranged; + +namespace CalamityMod.Projectiles.Ranged +{ + public class PressurizedBubbleStream : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public static int FireTime = 60; + public static int ChargeupTime = 12; + public float Progress => 1 - Projectile.timeLeft / (float)FireTime; + public bool ChargingUp => Projectile.timeLeft > FireTime; + public float ChargeupProgress => (ChargeupTime - (Projectile.timeLeft - FireTime)) / (float)ChargeupTime; + + public Particle chargeBubble; + public Player Owner => Main.player[Projectile.owner]; + + public ref float PulseTimer => ref Projectile.localAI[0]; + public ref float PrevPulseTimer => ref Projectile.localAI[1]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pressurized Bubble Stream"); + } + + public override void SetDefaults() + { + Projectile.width = 12; + Projectile.height = 12; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 1; + Projectile.extraUpdates = 4; + Projectile.timeLeft = FireTime + ChargeupTime; + } + + public override bool ShouldUpdatePosition() + { + return !ChargingUp; + } + + public override void AI() + { + ChargeupTime = 60; + + if (ChargingUp) + { + float bubbleRotation = Owner.itemRotation - (MathHelper.PiOver4 / 3f * Owner.direction); + if (Owner.direction < 0) + bubbleRotation += MathHelper.Pi; + + Vector2 bubblePosition = Owner.Center - Vector2.UnitY * 4f + bubbleRotation.ToRotationVector2() * 55f; + + Projectile.Center = bubblePosition; + Projectile.velocity = Vector2.UnitX.RotatedBy(bubbleRotation) * Projectile.velocity.Length(); + + if (chargeBubble == null) + { + chargeBubble = new GenericBubbleParticle(bubblePosition, Vector2.Zero, 0.4f, Owner.itemRotation, ChargeupTime / Projectile.extraUpdates); + GeneralParticleHandler.SpawnParticle(chargeBubble); + } + else + { + chargeBubble.Position = bubblePosition; + chargeBubble.Rotation = Owner.itemRotation; + chargeBubble.Scale = MathHelper.Lerp(0.4f, 1.4f, (float)Math.Sqrt(ChargeupProgress)); + } + return; + } + + if (Projectile.timeLeft == FireTime) + { + float bubbleRotation = Owner.itemRotation - (MathHelper.PiOver4 / 3f * Owner.direction); + if (Owner.direction < 0) + bubbleRotation += MathHelper.Pi; + + Vector2 bubblePosition = Owner.Center - Vector2.UnitY * 4f + bubbleRotation.ToRotationVector2() * 55f; + + SoundEngine.PlaySound(ReedBlowgun.BubbleBurstSound, bubblePosition); + } + + Projectile.velocity *= 0.985f; + PulseTimer--; + Lighting.AddLight(Projectile.Center, 0f, 0f, 0.5f); + + //Pulse + if (PulseTimer <= 0 && Progress < 0.7f) + { + if (PrevPulseTimer == 0) + PrevPulseTimer = 2; + else + PrevPulseTimer *= 2; + + PulseTimer = PrevPulseTimer * 2f; + + Color pulseColor = Main.rand.NextBool() ? (Main.rand.NextBool() ? Color.SkyBlue : Color.LightSkyBlue) : (Main.rand.NextBool() ? Color.LightBlue : Color.DeepSkyBlue); + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, pulseColor, new Vector2(0.5f, 1f), Projectile.velocity.ToRotation(), 0.05f, 0.2f + 0.3f * (1 - Progress), 30); + GeneralParticleHandler.SpawnParticle(pulse); + + int numDust = 18; + + for (int i = 0; i < numDust; i++) + { + Vector2 ringSpeed = new Vector2((float)Math.Cos(i / (float)numDust * MathHelper.TwoPi), (float)Math.Sin(i / (float)numDust * MathHelper.TwoPi) * 0.5f).RotatedBy(Projectile.velocity.ToRotation() + MathHelper.PiOver2) * (3.5f * (1 - Progress) + 3f) ; + Dust ringDust = Dust.NewDustPerfect(Projectile.position, 211, ringSpeed, 100, default, 1.25f); + ringDust.noGravity = true; + + } + } + + //Bubbles + if (!Main.rand.NextBool(3)) + { + Gore bubble = Gore.NewGorePerfect(Projectile.GetSource_FromAI(), Projectile.position, Projectile.velocity * 0.2f + Main.rand.NextVector2Circular(1f, 1f) * Progress, 411); + bubble.timeLeft = 8 + Main.rand.Next(6); + bubble.scale = Main.rand.NextFloat(0.6f, 1f) * (1 + Progress * 0.4f); + bubble.type = Main.rand.NextBool(3) ? 412 : 411; + } + + //Water trail + for (int i = 0; i < 6; i++) + { + Dust waterDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.9f); + waterDust.noGravity = true; + waterDust.velocity *= 0.5f; + waterDust.velocity -= Projectile.velocity * 0.1f; + } + } + + public override void Kill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.Item21, Projectile.position); + int bubbleCount = 25 + Main.rand.Next(15); + + for (int i = 0; i <= bubbleCount; i++) + { + Gore bubble = Gore.NewGorePerfect(Projectile.GetSource_Death(), Projectile.position, Projectile.velocity * 0.3f + Main.rand.NextVector2Circular(4f, 4f), 411); + bubble.timeLeft = 8 + Main.rand.Next(6); + bubble.scale = Main.rand.NextFloat(0.6f, 1f) * (1 + Progress * 0.4f); + bubble.type = Main.rand.NextBool(3) ? 412 : 411; + } + } + } +} diff --git a/Projectiles/Ranged/SandWater.cs b/Projectiles/Ranged/SandWater.cs deleted file mode 100644 index 303af7e9a1..0000000000 --- a/Projectiles/Ranged/SandWater.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Microsoft.Xna.Framework; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.Audio; -namespace CalamityMod.Projectiles.Ranged -{ - public class SandWater : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Water"); - } - - public override void SetDefaults() - { - Projectile.width = 12; - Projectile.height = 12; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 1; - Projectile.timeLeft = 60; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, 0f, 0f, 0.5f); - for (int num457 = 0; num457 < 10; num457++) - { - int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.9f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.5f; - Main.dust[num458].velocity += Projectile.velocity * 0.1f; - } - } - - public override void Kill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item21, Projectile.position); - for (int dust = 0; dust <= 40; dust++) - { - float num463 = (float)Main.rand.Next(-10, 11); - float num464 = (float)Main.rand.Next(-10, 11); - float num465 = (float)Main.rand.Next(3, 9); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 33, 0f, 0f, 100, default, 0.6f); - Dust dust2 = Main.dust[num467]; - dust2.noGravity = true; - dust2.position.X = Projectile.Center.X; - dust2.position.Y = Projectile.Center.Y; - dust2.position.X += (float)Main.rand.Next(-10, 11); - dust2.position.Y += (float)Main.rand.Next(-10, 11); - dust2.velocity.X = num463; - dust2.velocity.Y = num464; - } - } - } -} diff --git a/Sounds/Custom/PistolShrimpBubbleBurst.ogg b/Sounds/Custom/PistolShrimpBubbleBurst.ogg new file mode 100644 index 0000000000..412ca23d4c Binary files /dev/null and b/Sounds/Custom/PistolShrimpBubbleBurst.ogg differ