diff --git a/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs b/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs index 029b50fe1b..9d364b2ec0 100644 --- a/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs +++ b/CalPlayer/DrawLayers/HeldItemGlowMaskLayer.cs @@ -84,6 +84,8 @@ namespace CalamityMod.CalPlayer.DrawLayers glowMask = ModContent.Request("CalamityMod/Items/Weapons/Melee/PrismaticBreakerGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/PulseRifleGlow").Value; + else if (itemType == ModContent.ItemType()) + glowMask = ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/GaussRifleGlow").Value; else if (itemType == ModContent.ItemType()) glowMask = ModContent.Request("CalamityMod/Items/Weapons/Magic/SoulPiercerGlow").Value; else if (itemType == ModContent.ItemType()) diff --git a/Items/Weapons/DraedonsArsenal/GaussRifle.cs b/Items/Weapons/DraedonsArsenal/GaussRifle.cs index ea4fe97f92..5988a7d135 100644 --- a/Items/Weapons/DraedonsArsenal/GaussRifle.cs +++ b/Items/Weapons/DraedonsArsenal/GaussRifle.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -22,34 +23,62 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal { CalamityGlobalItem modItem = Item.Calamity(); - Item.width = 112; - Item.height = 36; + Item.width = 70; + Item.height = 30; Item.DamageType = DamageClass.Ranged; - Item.damage = 150; - Item.knockBack = 30f; - Item.useAnimation = Item.useTime = 32; + Item.damage = 100; + Item.knockBack = 0.2f; + Item.useTime = Item.useAnimation = 10; Item.autoReuse = true; Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = CommonCalamitySounds.GaussWeaponFire; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/GaussFire") with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0.5f, 0.65f) }; Item.noMelee = true; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 27f; + Item.shootSpeed = 7f; modItem.UsesCharge = true; modItem.MaxCharge = 135f; - modItem.ChargePerUse = 0.1125f; + modItem.ChargePerUse = 0.0225f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Projectile.NewProjectile(source, position + velocity * 6, velocity.RotatedByRandom(0.03f), ModContent.ProjectileType(), damage, knockback, player.whoAmI); return false; } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/DraedonsArsenal/GaussRifleGlow").Value); + } + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; + + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 7f; + Vector2 itemSize = new Vector2(70, 30); + Vector2 itemOrigin = new Vector2(-18, 6); + + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); + + base.UseStyle(player, heldItemFrame); + } + public override void UseItemFrame(Player player) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + if (animProgress < 0.4f) + rotation += -0.025f * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); + } public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); diff --git a/Items/Weapons/DraedonsArsenal/GaussRifle.png b/Items/Weapons/DraedonsArsenal/GaussRifle.png index f1e885da7d..ac001b522d 100644 Binary files a/Items/Weapons/DraedonsArsenal/GaussRifle.png and b/Items/Weapons/DraedonsArsenal/GaussRifle.png differ diff --git a/Items/Weapons/DraedonsArsenal/GaussRifleGlow.png b/Items/Weapons/DraedonsArsenal/GaussRifleGlow.png new file mode 100644 index 0000000000..89cc2dc642 Binary files /dev/null and b/Items/Weapons/DraedonsArsenal/GaussRifleGlow.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.DraedonsArsenal.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.DraedonsArsenal.hjson index 248ea0cf93..b4d6f73a7e 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.DraedonsArsenal.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.DraedonsArsenal.hjson @@ -50,7 +50,13 @@ GaussPistol: { GaussRifle: { DisplayName: Gauss Rifle - Tooltip: Fires a devastating powerful high-velocity blast with absurd knockback + Tooltip: + ''' + A magnet powered energy rifle that fires piercing shots, creating magnetic implosions that pull in weak enemies on hit + Implosions only spawn on the first enemy hit by the beam + [c/1FFBFF:'Many soldiers underestimate the destructive capabilities of magnetism.] + [c/1FFBFF:This rifle has reliably pulled in skeptics of its crushing efficiency.'] + ''' } HeavyLaserRifle: { diff --git a/Projectiles/DraedonsArsenal/GaussRifleBlast.cs b/Projectiles/DraedonsArsenal/GaussRifleBlast.cs index c45efa1f29..cc03f8632e 100644 --- a/Projectiles/DraedonsArsenal/GaussRifleBlast.cs +++ b/Projectiles/DraedonsArsenal/GaussRifleBlast.cs @@ -1,8 +1,6 @@ -using System; -using CalamityMod.Items.Weapons.DraedonsArsenal; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.Projectiles.DraedonsArsenal @@ -11,59 +9,97 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { public new string LocalizationCategory => "Projectiles.Misc"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public float Time - { - get => Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - public override void SetDefaults() { - Projectile.width = Projectile.height = 40; + Projectile.width = Projectile.height = 20; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.extraUpdates = 1; - Projectile.timeLeft = 300; + Projectile.timeLeft = 600; + Projectile.extraUpdates = 0; + Projectile.penetrate = -1; + Projectile.tileCollide = true; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } - public override void AI() { - Time++; - Projectile.tileCollide = Time > 3f; - if (!Main.dedServ) + if (Projectile.timeLeft == 600) { - // Idle dust. - for (int i = 0; i < 10; i++) + for (int i = 0; i < 3; i++) { - float angle = i / 10f * MathHelper.TwoPi; - for (int j = 0; j < 4; j++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 263); - dust.velocity = angle.ToRotationVector2().RotatedByRandom(0.25f) * Main.rand.NextFloat(6f, 8f); - dust.noGravity = true; - dust.scale = 1.6f; - } - } - // Ring dust. - for (int i = 0; i < 4; i++) - { - float angle = Projectile.velocity.ToRotation() + (i / 4f * MathHelper.TwoPi) + Time / 24f; - float radius = (float)Math.Sin(Time / 7.5f) * 40f + 10f; - Dust dust = Dust.NewDustPerfect(Projectile.Center + angle.ToRotationVector2() * radius, 226); - dust.velocity = Vector2.Zero; - dust.noGravity = true; - dust.scale = 1.5f; + Particle Square = new GlowSquareParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(1f, 3f), false, 15, Main.rand.NextFloat(0.5f, 1.2f), Color.Goldenrod, false, Main.rand.NextFloat(-3, 3)); + GeneralParticleHandler.SpawnParticle(Square); } } + if (Projectile.extraUpdates < 30 && Projectile.timeLeft % 3 == 0) + Projectile.extraUpdates++; + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (Projectile.timeLeft % 2 == 0 && targetDist < 1400 && Projectile.timeLeft <= 585) + { + float cLerp = Utils.GetLerpValue(500, 600, Projectile.timeLeft); + Particle spark = new GlowSparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 7, 0.08f, Color.Lerp(Color.Gold, Color.Goldenrod, cLerp), new Vector2(0.3f, 1), true, true); + GeneralParticleHandler.SpawnParticle(spark); + } + if (Main.rand.NextBool(7)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), 267); + dust.scale = Main.rand.NextFloat(0.5f, 1.1f); + dust.velocity = Projectile.velocity * Main.rand.NextFloat(-3, 3); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.Gold : Color.Goldenrod; + } + if (Projectile.timeLeft == 600) + { + Particle pulse = new GlowSparkParticle(Projectile.Center, Projectile.velocity * 3, false, 8, 0.042f, Color.Goldenrod, new Vector2(1.5f, 0.9f), true); + GeneralParticleHandler.SpawnParticle(pulse); + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + Particle spark = new GlowSparkParticle(Projectile.Center, Projectile.velocity, false, 8, MathHelper.Clamp(0.06f - Projectile.numHits * 0.01f, 0f, 0.06f), Color.Goldenrod * 0.9f, new Vector2(1, 0.5f), true); + GeneralParticleHandler.SpawnParticle(spark); + + if (Projectile.numHits == 0) + { + Particle bolt2 = new CustomPulse(target.Center, Vector2.Zero, Color.Gold * 0.55f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 1.4f, 0, 23); + GeneralParticleHandler.SpawnParticle(bolt2); + Particle bolt3 = new CustomPulse(target.Center, Vector2.Zero, Color.Gold * 0.35f, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 1.6f, 0, 18); + GeneralParticleHandler.SpawnParticle(bolt3); + + for (int i = 0; i < 8; i++) + { + Vector2 dustVel = Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(3f, 7f); + Dust dust = Dust.NewDustPerfect(target.Center + dustVel * 5, 267, -dustVel * 0.5f, 0, default, Main.rand.NextFloat(0.5f, 1f)); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.Gold : Color.Goldenrod; + } + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 3, 0, Projectile.owner); + } + for (int i = 0; i < MathHelper.Clamp(5 - Projectile.numHits, 1, 5); i++) + { + Particle Square = new GlowSquareParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(1f, 3f), false, 18, Main.rand.NextFloat(0.8f, 1.8f), Color.Goldenrod, false, Main.rand.NextFloat(-3, 3)); + GeneralParticleHandler.SpawnParticle(Square); + } + + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.84f); + if (Projectile.damage < 1) + Projectile.damage = 1; } public override void OnKill(int timeLeft) { - if (Main.myPlayer == Projectile.owner) + for (int i = 0; i < 5; i++) { - SoundEngine.PlaySound(GaussRifle.FireSound, Projectile.Center); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), 66); + dust.scale = Main.rand.NextFloat(0.5f, 1.1f); + dust.velocity = Projectile.velocity.RotateRandom(0.3f) * Main.rand.NextFloat(1, 3); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.LightYellow : Color.Gold; + dust.noLight = true; } } } diff --git a/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs b/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs index 4b65478c95..86d085f658 100644 --- a/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs +++ b/Projectiles/DraedonsArsenal/GaussRifleExplosion.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -9,41 +10,37 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public new string LocalizationCategory => "Projectiles.Misc"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public float Time - { - get => Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - public override void SetDefaults() { - Projectile.width = Projectile.height = 500; + Projectile.width = Projectile.height = 200; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.tileCollide = false; + Projectile.timeLeft = 12; Projectile.penetrate = -1; - Projectile.timeLeft = 20; + Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 12; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - Time++; - if (!Main.dedServ) + for (int i = 0; i < Main.maxNPCs; i++) { - for (int i = 0; i < 50; i++) + NPC target = Main.npc[i]; + if (target.CanBeMoved(true) && target.CanBeChasedBy(Projectile, false)) { - float angle = i / 30f * MathHelper.TwoPi; - Dust dust = Dust.NewDustPerfect(Projectile.Center, 261); - dust.velocity = angle.ToRotationVector2(); - dust.velocity = dust.velocity.RotatedByRandom(0.4f); - dust.velocity = dust.velocity.RotatedBy(Time / 60f * MathHelper.ToRadians(720f)); - dust.velocity *= Main.rand.NextFloat(20f, 50f); - dust.scale = Main.rand.NextFloat(1.2f, 1.6f); - dust.noGravity = true; + if (target != null && !CalamityPlayer.areThereAnyDamnBosses) + { + if (Vector2.Distance(target.Center, Projectile.Center) > 5 && Vector2.Distance(target.Center, Projectile.Center) < 500) + { + target.velocity += target.Center.DirectionTo(Projectile.Center).SafeNormalize(Vector2.UnitX) * 0.4f; + target.Center += target.Center.DirectionTo(Projectile.Center).SafeNormalize(Vector2.UnitX) * 0.8f; + } + } } } } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.5f * Projectile.scale, targetHitbox); } } diff --git a/Sounds/Item/GaussFire.ogg b/Sounds/Item/GaussFire.ogg new file mode 100644 index 0000000000..00a153e283 Binary files /dev/null and b/Sounds/Item/GaussFire.ogg differ