diff --git a/Items/Weapons/Ranged/FlakToxicannon.cs b/Items/Weapons/Ranged/FlakToxicannon.cs index 78d2f57a2b..cbebae4cc0 100644 --- a/Items/Weapons/Ranged/FlakToxicannon.cs +++ b/Items/Weapons/Ranged/FlakToxicannon.cs @@ -35,7 +35,6 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useTime = Item.useAnimation = 44; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; - Item.width = 88; Item.height = 28; Item.noMelee = true; diff --git a/Items/Weapons/Ranged/Leviatitan.cs b/Items/Weapons/Ranged/Leviatitan.cs index 2130046725..f5afd38582 100644 --- a/Items/Weapons/Ranged/Leviatitan.cs +++ b/Items/Weapons/Ranged/Leviatitan.cs @@ -1,6 +1,12 @@ -using CalamityMod.Projectiles.Ranged; +using System.Diagnostics.Metrics; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Rogue; +using Microsoft.Build.Tasks; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -10,46 +16,44 @@ namespace CalamityMod.Items.Weapons.Ranged public class Leviatitan : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() { Item.width = 82; Item.height = 28; - Item.damage = 77; + Item.damage = 117; Item.DamageType = DamageClass.Ranged; - Item.useTime = 10; - Item.useAnimation = 10; - Item.useStyle = ItemUseStyleID.Shoot; + Item.useTime = Item.useAnimation = 18; + Item.noUseGraphic = true; + Item.channel = true; Item.noMelee = true; Item.knockBack = 5f; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.UseSound = SoundID.Item92; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = .4f, Pitch = -.7f, PitchVariance = 0.1f }; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 12f; - Item.useAmmo = AmmoID.Bullet; + Item.useStyle = ItemUseStyleID.Shoot; Item.Calamity().canFirePointBlankShots = true; + Item.useAmmo = AmmoID.Bullet; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-15, 0); - } + // Obviously we don't want multiple holdouts existing at the same time. + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0; + + // Spawning the holdout won't consume ammo. + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] != 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 Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float SpeedX = velocity.X + Main.rand.Next(-10, 11) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-10, 11) * 0.05f; + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); - if (type == ProjectileID.Bullet) - { - if (Main.rand.NextBool(3)) - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * 1.5), knockback, player.whoAmI); - else - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - } - else - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, 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); return false; } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 8cf1520dc0..84f95c7e74 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -693,7 +693,12 @@ Kingsbane: { Leviatitan: { DisplayName: Leviatitan - Tooltip: Converts musket balls into toxic and normal water blasts + Tooltip: + ''' + Converts musket balls into high velocity aqua blasts + Fires homing aberrations that shred enemy defense every 7th shot + to vomit a meteor that explodes on hit + ''' } LunarianBow: { diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 00a4491211..9bcc2d7f26 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -253,3 +253,4 @@ WildfireBloomFlare.DisplayName: Wildfire Flare WulfrumScrapBullet.DisplayName: High Speed Scrap NitroShot.DisplayName: Nitro Shot ChargedBlastSplit.DisplayName: Charged Blast Split +LeviatitanAberration.DisplayName: Leviatitan Aberration diff --git a/Projectiles/Ranged/AquaBlast.cs b/Projectiles/Ranged/AquaBlast.cs index 0397ad3904..de5536f071 100644 --- a/Projectiles/Ranged/AquaBlast.cs +++ b/Projectiles/Ranged/AquaBlast.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -53,6 +54,16 @@ namespace CalamityMod.Projectiles.Ranged Main.dust[dust].noGravity = true; Main.dust[dust].velocity = dspeed; } + if (Projectile.timeLeft <= 580 && Projectile.timeLeft % 3 == 0) + { + Particle spark = new LineParticle(Projectile.Center - Projectile.velocity + Main.rand.NextVector2Circular(20, 20), -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), 75, -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) diff --git a/Projectiles/Ranged/AquaBlastToxic.cs b/Projectiles/Ranged/AquaBlastToxic.cs index 963152fa75..0edbad3be6 100644 --- a/Projectiles/Ranged/AquaBlastToxic.cs +++ b/Projectiles/Ranged/AquaBlastToxic.cs @@ -1,5 +1,9 @@ -using Microsoft.Xna.Framework; +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; @@ -45,12 +49,15 @@ namespace CalamityMod.Projectiles.Ranged Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.ToRadians(90) * Projectile.direction; Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0.4f / 255f); - for (int i = 0; i < 2; i++) + if (Projectile.timeLeft <= 580 && Projectile.timeLeft % 3 == 0) { - Vector2 dspeed = -Projectile.velocity * Main.rand.NextFloat(0.5f * 0.8f); - int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GemEmerald, 0f, 0f, 100, default, 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity = dspeed; + Particle spark = new LineParticle(Projectile.Center - Projectile.velocity + Main.rand.NextVector2Circular(20, 20), -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), 75, -Projectile.velocity.RotatedByRandom(0.1) * Main.rand.NextFloat(0.1f, 0.3f), 0, default, Main.rand.NextFloat(0.5f, 1.2f)); + dust.noGravity = true; } } @@ -60,6 +67,11 @@ namespace CalamityMod.Projectiles.Ranged { Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GemEmerald, 0f, 0f, 100, default, 1f); } + for (int i = 0; i <= 3; i++) + { + Particle skull = new DesertProwlerSkullParticle(Projectile.Center, new Vector2(2.5f, 2.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), Main.rand.NextBool() ? Color.LightGreen: Color.Lime, Color.LimeGreen, Main.rand.NextFloat(0.2f, 0.9f), 175); + GeneralParticleHandler.SpawnParticle(skull); + } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Projectiles/Ranged/LeviatitanAberration.cs b/Projectiles/Ranged/LeviatitanAberration.cs new file mode 100644 index 0000000000..8f51f3bd11 --- /dev/null +++ b/Projectiles/Ranged/LeviatitanAberration.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class LeviatitanAberration : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Summon/GastricBelcher"; + 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; + Projectile.height = 40; + Projectile.aiStyle = ProjAIStyleID.Arrow; + Projectile.friendly = true; + Projectile.tileCollide = false; + 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); + + //Rotation + Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); + Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.ToRadians(360) * Projectile.direction; + + //Update frames + if (Projectile.frameCounter++ % 6 == 0) + { + Projectile.frame++; + } + if (Projectile.frame >= Main.projFrames[Projectile.type]) + { + Projectile.frame = 0; + } + } + public override void OnSpawn(IEntitySource source) + { + int dustAmt = 36; + for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) + { + 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; + } + 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) + { + target.AddBuff(ModContent.BuffType(), 120); + SoundEngine.PlaySound(SoundID.NPCDeath1 with { Volume = SoundID.NPCDeath1.Volume * 0.5f }, Projectile.Center); + } + public override void OnKill(int timeLeft) + { + for (int d = 0; d < 15; ++d) + { + int idx = Dust.NewDust(Projectile.Center - Vector2.One * 10f, 50, 50, DustID.Blood, 0f, -2f, 0, default, 1f); + Dust dust = Main.dust[idx]; + dust.velocity /= 2f; + } + } + } +} diff --git a/Projectiles/Ranged/LeviatitanHoldout.cs b/Projectiles/Ranged/LeviatitanHoldout.cs new file mode 100644 index 0000000000..8c275eab72 --- /dev/null +++ b/Projectiles/Ranged/LeviatitanHoldout.cs @@ -0,0 +1,118 @@ +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.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 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) + { + // We use the velocity of this projectile as its direction vector. + Vector2 direction = Projectile.velocity.SafeNormalize(Vector2.Zero); + + Owner.PickAmmo(Owner.ActiveItem(), out _, out float itemShootSpeed, out int itemDamage, out float itemKnockback, out int rocketTypeShot); + + Vector2 smokeVel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5; + + if (Main.rand.NextBool(3)) + Projectile.NewProjectileDirect( + Projectile.GetSource_FromThis(), + GunTipPosition, + direction * itemShootSpeed, + ProjectileType(), + itemDamage, + itemKnockback, + Projectile.owner, + ownerToMouse.Length()); + else + Projectile.NewProjectileDirect( + Projectile.GetSource_FromThis(), + GunTipPosition, + direction * itemShootSpeed, + ProjectileType(), + itemDamage, + itemKnockback, + Projectile.owner, + ownerToMouse.Length()); + + // 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 = 18f; + + 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.5f, 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.65f, Volume = 0.5f }, GunTipPosition); + } + ShootingTimer = 0f; + ShotsFired++; + if (ShotsFired == 7) + { + int monsterCount; + monsterCount = 2; + for (int a = 0; a < monsterCount; a++) + { + float projSpeed = itemShootSpeed; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center + Main.rand.NextVector2Circular(30, 30), (Owner.Calamity().mouseWorld - Owner.MountedCenter).SafeNormalize(Vector2.Zero) * projSpeed, ModContent.ProjectileType(), (int)(itemDamage * 1.5f), itemKnockback); + SoundEngine.PlaySound(SoundID.Zombie38 with { Volume = SoundID.Zombie38.Volume * 0.5f }, mountedCenter); + } + } + if (ShotsFired >= 8) + ShotsFired = 0; + } + ShootingTimer++; + } + public override void OnSpawn(IEntitySource source) + { + base.OnSpawn(source); + SoundEngine.PlaySound(SoundID.Item108 with { Volume = 0.7f }, Projectile.Center); + } + } +}