diff --git a/Items/Weapons/Ranged/Leviatitan.cs b/Items/Weapons/Ranged/Leviatitan.cs index 40242f1024..76d735c82f 100644 --- a/Items/Weapons/Ranged/Leviatitan.cs +++ b/Items/Weapons/Ranged/Leviatitan.cs @@ -1,4 +1,5 @@ -using System.Diagnostics.Metrics; +using System; +using System.Diagnostics.Metrics; using CalamityMod.Particles; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Ranged; @@ -16,41 +17,108 @@ namespace CalamityMod.Items.Weapons.Ranged public class Leviatitan : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + // Every sixth shot fires homing Aberrations, then resets the counter to 2. + // This is intentional so you don't get the Aberrations instantly when you start firing and have to play around it. + private int shotCounter = 1; + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + } public override void SetDefaults() { Item.width = 82; Item.height = 28; - Item.damage = 97; + Item.damage = 121; Item.DamageType = DamageClass.Ranged; - Item.useTime = Item.useAnimation = 26; - Item.noUseGraphic = true; - Item.channel = true; + Item.useTime = Item.useAnimation = 18; //Try not to change this if you can help it Item.noMelee = true; Item.knockBack = 5f; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = .4f, Pitch = -.7f, PitchVariance = 0.1f }; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/FlakKrakenShoot") { Pitch = 0.65f, Volume = 0.4f }; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 13f; Item.useStyle = ItemUseStyleID.Shoot; + Item.useAmmo = AmmoID.Bullet; + Item.Calamity().canFirePointBlankShots = true; } - // Obviously we don't want multiple holdouts existing at the same time. - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0; + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - // Makes the rotation of the mouse around the player sync in multiplayer. - public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + public override bool AltFunctionUse(Player player) + { + return true; + } + public override bool CanUseItem(Player player) + { + Item.UseSound = player.altFunctionUse == 2 ? SoundID.NPCHit56 : new SoundStyle("CalamityMod/Sounds/Item/FlakKrakenShoot") { Pitch = 0.65f, Volume = 0.3f }; + return base.CanUseItem(player); + } + public override float UseSpeedMultiplier(Player player) => player.altFunctionUse == 2 ? (1f / 3f) : 1f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - - // We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out. - holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + // Reposition to the gun's tip. Calculated seperately due to the two different shot styles. + Vector2 boulderPos = position + new Vector2(74f, player.direction * (Math.Abs(velocity.SafeNormalize(Vector2.Zero).X) < 0.02f ? -2f : -8f)).RotatedBy(velocity.ToRotation()); + Vector2 shotPos = position + new Vector2(74f, player.direction * (Math.Abs(velocity.SafeNormalize(Vector2.Zero).X) < 0.02f ? -6f : 3f)).RotatedBy(velocity.ToRotation()); + if (player.altFunctionUse == 2) + { + int index = Projectile.NewProjectile(source, boulderPos, velocity * 0.7f, ModContent.ProjectileType(), (int)(damage * 2f), knockback, player.whoAmI); + } + else + { + Projectile.NewProjectile(source, shotPos, velocity, Item.shoot, damage, knockback, player.whoAmI); + } + if (shotCounter == 7) + { + SoundEngine.PlaySound(SoundID.Zombie38 with { Volume = SoundID.Zombie38.Volume * 0.5f }); + for (int i = 0; i <= 1; i++) + { + float projSpeed = Item.shootSpeed; + Projectile.NewProjectile(source, position + Main.rand.NextVector2Circular(150, 150), velocity * projSpeed, ModContent.ProjectileType(), (int)(damage * 1.3), knockback, player.whoAmI); + } + } + shotCounter++; + if (shotCounter > 7) + shotCounter = 2; return false; } + + //Thanks to Xyk's incredible recoil code, we give both left click and right click different recoils without having to use a holdout. + 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; + + float pullback = 7f; + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + if (animProgress < 0.1f) + pullback -= (2.75f) * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2); + + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * pullback; + Vector2 itemSize = new Vector2(52, 28); + Vector2 itemOrigin = new Vector2(-24, 4); + + 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 += (player.altFunctionUse == 2 ? -0.15f : 0) * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); + } } } + diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 65c645dca9..92ad8e039f 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -685,8 +685,8 @@ Leviatitan: { Tooltip: ''' Fires high velocity aqua blasts - Releases homing aberrations that shred enemy defense on every 6th shot - while holding to vomit a meteor that explodes on hit + Releases homing aberrations that shred enemy defense every six shots + to vomit a meteor that explodes on hit ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 11209f6fc1..42979baa91 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -252,3 +252,6 @@ HellbornProj.DisplayName: Hell-born Gunblast HellbornShell.DisplayName: Hell's Shell RubicoPrimeMag.DisplayName: Rubico Prime Mag MegalodonShot.DisplayName: Megalodon Shot +LeviatitanAberration.DisplayName: Leviatitan Aberration +LeviatitanMeteor.DisplayName: Leviatitan Meteor +LeviatitanExplosion.DisplayName: Leviatitan Explosion diff --git a/Projectiles/Ranged/AquaBlast.cs b/Projectiles/Ranged/AquaBlast.cs index 91d85cc585..77fd2a7062 100644 --- a/Projectiles/Ranged/AquaBlast.cs +++ b/Projectiles/Ranged/AquaBlast.cs @@ -1,6 +1,13 @@ -using CalamityMod.Particles; +using System.Diagnostics.Contracts; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -9,21 +16,23 @@ namespace CalamityMod.Projectiles.Ranged public class AquaBlast : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; + public override void SetStaticDefaults() { - Main.projFrames[Projectile.type] = 4; + Main.projFrames[Projectile.type] = 20; } + public int spreadDust = 0; public override void SetDefaults() { - Projectile.width = 12; - Projectile.height = 12; + Projectile.width = 36; + Projectile.height = 26; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.penetrate = 1; Projectile.timeLeft = 600; - Projectile.DamageType = DamageClass.Ranged; Projectile.extraUpdates = 2; + Projectile.DamageType = DamageClass.Ranged; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } @@ -31,15 +40,16 @@ namespace CalamityMod.Projectiles.Ranged { //Animation Projectile.frameCounter++; - if (Projectile.frameCounter > 5) + if (Projectile.frameCounter > 21) { Projectile.frame++; Projectile.frameCounter = 0; } - if (Projectile.frame > 3) + if (Projectile.frame > 19) { Projectile.frame = 0; } + Projectile.frame = Projectile.frameCounter / 4 % Main.projFrames[Projectile.type]; //Rotation Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); @@ -47,26 +57,76 @@ namespace CalamityMod.Projectiles.Ranged Lighting.AddLight(Projectile.Center, Color.AliceBlue.ToVector3() * 0.5f); - - if (Projectile.timeLeft <= 580 && Projectile.timeLeft % 5 == 0) + if (Projectile.timeLeft <= 593) { - Particle spark = new LineParticle(Projectile.Center - Projectile.velocity + Main.rand.NextVector2Circular(15, 15), -Projectile.velocity * Main.rand.NextFloat(0.2f, 1.8f), false, Main.rand.Next(9, 20 + 1), Main.rand.NextFloat(0.8f, 1.2f), Color.Lerp(Color.Cyan, Color.AliceBlue, Main.rand.NextFloat(0.35f)) * Main.rand.NextFloat(0.15f, 0.5f)); - GeneralParticleHandler.SpawnParticle(spark); - } - if (Main.rand.NextBool(6)) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), 103, -Projectile.velocity.RotatedByRandom(0.1) * Main.rand.NextFloat(0.1f, 0.3f), 0, default, Main.rand.NextFloat(0.5f, 1.2f)); - dust.noGravity = true; + for (int i = 0; i < 2; i++) + { + SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity / 0.18f, Projectile.velocity * 0.01f, false, 5, 1.9f, Color.SeaGreen, true); + GeneralParticleHandler.SpawnParticle(spark); + } + if (Main.rand.NextBool(2)) + { + Gore bubble = Gore.NewGorePerfect(Projectile.GetSource_FromAI(), Projectile.position, Projectile.velocity * 0.2f + Main.rand.NextVector2Circular(1f, 1f), 411); + bubble.timeLeft = 6 + Main.rand.Next(7); + bubble.scale = Main.rand.NextFloat(0.6f, 0.8f); + bubble.type = Main.rand.NextBool(3) ? 412 : 411; + } + if (Main.rand.NextBool()) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(6 + spreadDust, 6 + spreadDust), !Main.rand.NextBool(5) ? 278 : 267, -Projectile.velocity * Main.rand.NextFloat(0.05f, 0.35f), 0, default, Main.rand.NextFloat(0.4f, 0.6f)); + dust.noGravity = true; + dust.color = !Main.rand.NextBool(5) ? Color.Aquamarine : Color.Aqua; + if (dust.type == 278) + dust.scale *= 0.7f; + } } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 60); + } + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(ModContent.BuffType(), 60); + } + public override void OnSpawn(IEntitySource source) + { + Vector2 smokeVel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5; + int smokeAmount = Main.rand.Next(8, 12 + 1); + for (int i = 0; i < smokeAmount; i++) + { + Particle smoke = new HeavySmokeParticle(Projectile.Center, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(1.2f, 2f), Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.3f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + GeneralParticleHandler.SpawnParticle(smoke); + } + } public override void OnKill(int timeLeft) { - for (int lol = 0; lol < 12; lol++) + SoundEngine.PlaySound(SoundID.ShimmerWeak1 with { Pitch = 0.35f }, Projectile.Center); + for (int i = 0; i < 5; ++i) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 103, new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f)); - dust.scale = Main.rand.NextFloat(0.5f, 1.2f); + int bloodLifetime = Main.rand.Next(22, 25); + float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); + Color bloodColor = Color.Lerp(Color.SkyBlue, Color.Aquamarine, Main.rand.NextFloat()); + bloodColor = Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f)); + + if (Main.rand.NextBool(20)) + bloodScale *= 2f; + + float randomSpeedMultiplier = Main.rand.NextFloat(1.25f, 2.25f); + Vector2 bloodVelocity = Main.rand.NextVector2Unit() * 2 * randomSpeedMultiplier; + bloodVelocity.Y -= 5f; + BloodParticle blood = new BloodParticle(Projectile.Center, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); } + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Aquamarine * 0.8f, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.05f, 22); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Aqua * 0.8f, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.04f, 22); + GeneralParticleHandler.SpawnParticle(blastRing2); + Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DeepSkyBlue, "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.2f, 22); + GeneralParticleHandler.SpawnParticle(blastRing3); + Particle orb2 = new GenericBloom(Projectile.Center, Vector2.Zero, Color.SkyBlue, 0.6f, 11, false, true); + GeneralParticleHandler.SpawnParticle(orb2); } } } diff --git a/Projectiles/Ranged/AquaBlast.png b/Projectiles/Ranged/AquaBlast.png index 91449ac4c5..3d5a42c1ee 100644 Binary files a/Projectiles/Ranged/AquaBlast.png and b/Projectiles/Ranged/AquaBlast.png differ diff --git a/Projectiles/Ranged/AquaBlastToxic.cs b/Projectiles/Ranged/AquaBlastToxic.cs deleted file mode 100644 index 0d54103098..0000000000 --- a/Projectiles/Ranged/AquaBlastToxic.cs +++ /dev/null @@ -1,80 +0,0 @@ -using CalamityMod.Graphics.Primitives; -using CalamityMod.Particles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class AquaBlastToxic : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 4; - } - - public override void SetDefaults() - { - Projectile.width = 12; - Projectile.height = 12; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 600; - Projectile.DamageType = DamageClass.Ranged; - Projectile.extraUpdates = 2; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; - } - - public override void AI() - { - //Animation - Projectile.frameCounter++; - if (Projectile.frameCounter > 5) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 3) - { - Projectile.frame = 0; - } - - //Rotation - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.ToRadians(90) * Projectile.direction; - - Lighting.AddLight(Projectile.Center, Color.Chartreuse.ToVector3() * 0.5f); - - if (Projectile.timeLeft <= 580 && Projectile.timeLeft % 5 == 0) - { - Particle spark = new LineParticle(Projectile.Center - Projectile.velocity + Main.rand.NextVector2Circular(15, 15), -Projectile.velocity * Main.rand.NextFloat(0.2f, 1.8f), false, Main.rand.Next(9, 20 + 1), Main.rand.NextFloat(0.8f, 1.2f), Color.Chartreuse * Main.rand.NextFloat(0.15f, 0.5f)); - GeneralParticleHandler.SpawnParticle(spark); - } - if (Main.rand.NextBool(6)) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), 102, -Projectile.velocity.RotatedByRandom(0.1) * Main.rand.NextFloat(0.1f, 0.3f), 0, default, Main.rand.NextFloat(0.5f, 1.2f)); - dust.noGravity = true; - } - } - - public override void OnKill(int timeLeft) - { - for (int lol = 0; lol < 12; lol++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 102, new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f)); - dust.scale = Main.rand.NextFloat(0.5f, 1.2f); - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - // Levi weapons are no longer venom themed - //target.AddBuff(BuffID.Venom, 120); - } - } -} diff --git a/Projectiles/Ranged/AquaBlastToxic.png b/Projectiles/Ranged/AquaBlastToxic.png deleted file mode 100644 index db383de083..0000000000 Binary files a/Projectiles/Ranged/AquaBlastToxic.png and /dev/null differ diff --git a/Projectiles/Ranged/LeviatitanAberration.cs b/Projectiles/Ranged/LeviatitanAberration.cs index 8f51f3bd11..077afea76b 100644 --- a/Projectiles/Ranged/LeviatitanAberration.cs +++ b/Projectiles/Ranged/LeviatitanAberration.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Dusts; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -21,10 +22,7 @@ namespace CalamityMod.Projectiles.Ranged public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 4; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; } - public override void SetDefaults() { Projectile.width = 40; @@ -35,13 +33,12 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; Projectile.timeLeft = 600; - Projectile.extraUpdates = 1; AIType = ProjectileID.Bullet; } public override void AI() { - CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 150f, 12f, 20f); + CalamityUtils.HomeInOnNPC(Projectile, true, 500f, 16f, 8f); //Rotation Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); @@ -56,33 +53,23 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.frame = 0; } + for (int i = 0; i < 3; i++) + { + int bloodDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height / 2, DustID.Blood, 0f, 0f, 100, default, 1f); + Main.dust[bloodDust].noGravity = true; + Main.dust[bloodDust].velocity *= 0.5f; + Main.dust[bloodDust].velocity += Projectile.velocity * 0.1f; + } } public override void OnSpawn(IEntitySource source) { - int dustAmt = 36; - for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) + for (int i = 0; i < 36; i++) { - int randomDust = Utils.SelectRandom(Main.rand, new int[] - { - 33, - 89 - }); - Vector2 direction = Vector2.Normalize(Projectile.velocity) * new Vector2(Projectile.width / 2f, Projectile.height) * 0.75f; - direction = direction.RotatedBy((double)((dustIndex - (dustAmt / 2f - 1f)) * MathHelper.TwoPi / dustAmt), default) + Projectile.Center; - Vector2 dustVel = direction - Projectile.Center; - int water = Dust.NewDust(direction + dustVel, 0, 0, randomDust, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); - Main.dust[water].noGravity = true; - Main.dust[water].velocity = dustVel; + Dust minion = Dust.NewDustPerfect(Projectile.Center, DustID.MoonBoulder); + minion.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 9f; + minion.scale = Main.rand.NextFloat(1.4f, 1.6f); + minion.noGravity = true; } - Particle shootPulse = new DirectionalPulseRing(Projectile.Center, - Vector2.Zero, - Color.LimeGreen * 0.7f, - new Vector2(0.5f, 1f), - Projectile.rotation, - 0.1f, - 0.4f, - 20); - GeneralParticleHandler.SpawnParticle(shootPulse); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { diff --git a/Projectiles/Ranged/LeviatitanExplosion.cs b/Projectiles/Ranged/LeviatitanExplosion.cs new file mode 100644 index 0000000000..fd318a87ec --- /dev/null +++ b/Projectiles/Ranged/LeviatitanExplosion.cs @@ -0,0 +1,30 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Ranged +{ + public class LeviatitanExplosion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + private static float ExplosionRadius = 112f; + + public override void SetDefaults() + { + //These shouldn't matter because its circular + Projectile.width = 112; + Projectile.height = 112; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius, targetHitbox); + } +} diff --git a/Projectiles/Ranged/LeviatitanHoldout.cs b/Projectiles/Ranged/LeviatitanHoldout.cs deleted file mode 100644 index ef2c863a44..0000000000 --- a/Projectiles/Ranged/LeviatitanHoldout.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.Metrics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CalamityMod.Particles; -using CalamityMod.Projectiles.BaseProjectiles; -using CalamityMod.Projectiles.Melee; -using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; -using Mono.Cecil; -using Terraria; -using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; -using static CalamityMod.Items.Weapons.Ranged.Leviatitan; -using static Terraria.ModLoader.ModContent; - -namespace CalamityMod.Items.Weapons.Ranged -{ - public class LeviatitanHoldout : BaseGunHoldoutProjectile - { - public override int AssociatedItemID => ItemType(); - public override string Texture => "CalamityMod/Items/Weapons/Ranged/Leviatitan"; - - - public override float MaxOffsetLengthFromArm => 38f; - public override float RecoilResolveSpeed => 0.1f; - public override float OffsetXUpwards => -10f; - public override float OffsetXDownwards => 2f; - public override float BaseOffsetY => -10f; - public override float OffsetYUpwards => 10f; - public override float OffsetYDownwards => 5f; - public ref float ShootingTimer => ref Projectile.ai[0]; - public ref float ShotsFired => ref Projectile.ai[1]; - public ref float ShootTimer => ref Projectile.ai[2]; - public int shotColor = 1; - public bool HasfiredMeteor = false; - public int time = 0; - - public override void HoldoutAI() - { - // The center of the player, taking into account if they have a mount or not. - Vector2 mountedCenter = Owner.MountedCenter; - - // The vector between the player and the mouse. - Vector2 ownerToMouse = Owner.Calamity().mouseWorld - mountedCenter; - - if (ShootingTimer >= HeldItem.useAnimation) - { - HasfiredMeteor = false; - // We use the velocity of this projectile as its direction vector. - Vector2 direction = Projectile.velocity.SafeNormalize(Vector2.Zero); - - Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 10; - Vector2 smokeVel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5; - - if (Owner.Calamity().mouseRight) - { - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ProjectileType(), Projectile.damage * 4, Projectile.knockBack * 3, Projectile.owner, ownerToMouse.Length()); - if (!Main.dedServ) - { - // By decreasing the offset length of the gun from the arms, we give an effect of recoil. - OffsetLengthFromArm = 9f; - - int smokeAmount = Main.rand.Next(8, 12 + 1); - for (int i = 0; i < smokeAmount; i++) - { - Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(1.2f, 2f), Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.3f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); - GeneralParticleHandler.SpawnParticle(smoke); - - } - SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/LeviatitanRoar") { Volume = 0.5f }, GunTipPosition); - SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/MagicRockSound") with { Pitch = -0.7f, Volume = 0.8f }, Projectile.Center); - } - HasfiredMeteor = true; - } - else - { - // Fire the projectiles - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(MathHelper.ToRadians(2f * shotColor)), ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, ownerToMouse.Length()); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(MathHelper.ToRadians(-2f * shotColor)), ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, ownerToMouse.Length()); - // Swap which is the top and bottom with every shot - shotColor = (shotColor == 1 ? -1 : 1); - - // Inside here go all the things that dedicated servers shouldn't spend resources on. - // Like visuals and sounds. - if (!Main.dedServ) - { - // By decreasing the offset length of the gun from the arms, we give an effect of recoil. - OffsetLengthFromArm = 25f; - - int smokeAmount = Main.rand.Next(8, 12 + 1); - for (int i = 0; i < smokeAmount; i++) - { - Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 1f), Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.3f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); - GeneralParticleHandler.SpawnParticle(smoke); - - } - SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/FlakKrakenShoot") { Pitch = 0.9f, Volume = 0.5f }, GunTipPosition); - SoundEngine.PlaySound(SoundID.Item108 with { Pitch = -0.5f, Volume = 0.8f }, Projectile.Center); - - } - } - - ShootingTimer = 0f; - ShotsFired++; - - if (ShotsFired == 6) - { - int monsterCount; - monsterCount = 2; - for (int a = 0; a < monsterCount; a++) - { - float projSpeed = 5; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center + Main.rand.NextVector2Circular(30, 30), (Owner.Calamity().mouseWorld - Owner.MountedCenter).SafeNormalize(Vector2.Zero) * projSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * 1.2f), Projectile.knockBack); - } - SoundEngine.PlaySound(SoundID.Zombie38 with { Volume = SoundID.Zombie38.Volume * 0.5f }, mountedCenter); - } - if (ShotsFired >= 6) - ShotsFired = 0; - } - if (!HasfiredMeteor || time % 3 == 0) - ShootingTimer++; - time++; - } - public override void OnSpawn(IEntitySource source) - { - base.OnSpawn(source); - } - } -} diff --git a/Projectiles/Ranged/LeviatitanMeteor.cs b/Projectiles/Ranged/LeviatitanMeteor.cs new file mode 100644 index 0000000000..1c728fd81e --- /dev/null +++ b/Projectiles/Ranged/LeviatitanMeteor.cs @@ -0,0 +1,103 @@ +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Particles; +using Terraria.DataStructures; +using System; + +namespace CalamityMod.Projectiles.Ranged +{ + public class LeviatitanMeteor : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Melee/AftershockRock"; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + public override void SetDefaults() + { + Projectile.width = 38; + Projectile.height = 38; + Projectile.friendly = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 600; + Projectile.DamageType = DamageClass.Ranged; + } + + public override void AI() + { + if (Projectile.velocity.Y < 25f) + Projectile.velocity.Y += 0.12f; + Projectile.rotation += Projectile.velocity.X * 0.05f; + + if (Projectile.timeLeft <= 594) + { + if (Main.rand.NextBool(3)) + { + MediumMistParticle SandCloud = new MediumMistParticle(Projectile.Center + new Vector2(25, 25).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1.3f) * Projectile.scale, (-Projectile.velocity * 0.2f).RotatedByRandom(0.2f) + (new Vector2(3, 3).RotatedByRandom(100)), Color.Peru, Color.PeachPuff, Main.rand.NextFloat(0.4f, 1.3f), 120f, Main.rand.NextFloat(0.03f, -0.03f)); + GeneralParticleHandler.SpawnParticle(SandCloud); + } + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.UnusedBrown, 0f, 0f, 100, default, Main.rand.NextFloat(0.75f, 1.2f)); + Main.dust[dust].velocity *= 0f; + } + } + public override void OnSpawn(IEntitySource source) + { + Vector2 smokeVel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5; + int smokeAmount = Main.rand.Next(8, 12 + 1); + for (int i = 0; i < smokeAmount; i++) + { + Particle smoke = new HeavySmokeParticle(Projectile.Center, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(1.2f, 2f), Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.3f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + } + } + public override void OnKill(int timeLeft) + { + if (Projectile.owner == Main.myPlayer) + { + SoundStyle explo = new("CalamityMod/Sounds/Item/MineralMortarExplode"); + SoundEngine.PlaySound(explo with { Volume = 0.9f }, Projectile.Center); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); + for (int i = 0; i < 8; i++) + { + Vector2 randVel = new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 0.7f); + Particle smoke = new HeavySmokeParticle(Projectile.Center + randVel, randVel, Color.Peru, Main.rand.Next(25, 35 + 1), Main.rand.NextFloat(0.9f, 2.3f), 0.4f); + GeneralParticleHandler.SpawnParticle(smoke); + MediumMistParticle SandCloud = new MediumMistParticle(Projectile.Center, randVel * 0.8f, Color.Peru, Color.PeachPuff, Main.rand.NextFloat(0.4f, 1.3f), 120f, Main.rand.NextFloat(0.03f, -0.03f)); + GeneralParticleHandler.SpawnParticle(SandCloud); + } + int debriAmount = Main.rand.Next(10, 15 + 1); + for (int debriIndex = 0; debriIndex < debriAmount; debriIndex++) + { + float angle = MathHelper.TwoPi / debriAmount * debriIndex; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(2f, 8f); + Particle debri = new StoneDebrisParticle(Projectile.Center, velocity, Color.Lerp(Color.White, Color.LightGray, Main.rand.NextFloat()), Main.rand.NextFloat(0.4f, 0.6f), Main.rand.Next(30, 45 + 1), Main.rand.NextFloat(MathHelper.Pi)); + GeneralParticleHandler.SpawnParticle(debri); + } + int mistAmount = Main.rand.Next(5, 8 + 1); + for (int mistIndex = 0; mistIndex < mistAmount; mistIndex++) + { + float angle = MathHelper.TwoPi / mistAmount * mistIndex; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(5f, 15f); + Particle boomMist = new MediumMistParticle(Projectile.Center, velocity, Color.SaddleBrown * 0.8f, Color.Transparent, Main.rand.NextFloat(.6f, 1.4f), Main.rand.NextFloat(200f, 400f)); + GeneralParticleHandler.SpawnParticle(boomMist); + } + Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Red, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), Projectile.width / 5000f, Projectile.width / 200f, 29, true, 0.7f); + GeneralParticleHandler.SpawnParticle(blastRing2); + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.SaddleBrown * 0.8f, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), Projectile.width / 5000f, Projectile.width / 300f, 29); + GeneralParticleHandler.SpawnParticle(blastRing); + } + } + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + return false; + } + } +}