diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index b6091a82c0..6a3a3b2563 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -195,6 +195,7 @@ namespace CalamityMod.CalPlayer public int PHAThammer = 0; public int StellarHammer = 0; public int GalaxyHammer = 0; + public bool despoilerNerf = false; public int NorfleetCounter = 0; public int hideOfDeusMeleeBoostTimer = 0; public int alcoholPoisonLevel = 0; diff --git a/Items/Weapons/Ranged/MolecularManipulator.cs b/Items/Weapons/Ranged/MolecularManipulator.cs deleted file mode 100644 index 231d923c00..0000000000 --- a/Items/Weapons/Ranged/MolecularManipulator.cs +++ /dev/null @@ -1,61 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Rarities; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Ranged -{ - public class MolecularManipulator : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Ranged"; - - public override void SetStaticDefaults() - { - ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; - } - public override void SetDefaults() - { - Item.width = 56; - Item.height = 34; - Item.damage = 580; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 20; - Item.useAnimation = 20; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 8f; - Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.rare = ModContent.RarityType(); - Item.UseSound = SoundID.Item33; - Item.autoReuse = true; - Item.shootSpeed = 25f; - Item.shoot = ModContent.ProjectileType(); - Item.Calamity().canFirePointBlankShots = true; - } - - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } - - 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); - return false; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(2). - AddIngredient(). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Ranged/MolecularManipulator.png b/Items/Weapons/Ranged/MolecularManipulator.png deleted file mode 100644 index ea6f70892c..0000000000 Binary files a/Items/Weapons/Ranged/MolecularManipulator.png and /dev/null differ diff --git a/Items/Weapons/Ranged/NullificationPistol.cs b/Items/Weapons/Ranged/NullificationPistol.cs index e826eda405..f0445990a4 100644 --- a/Items/Weapons/Ranged/NullificationPistol.cs +++ b/Items/Weapons/Ranged/NullificationPistol.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged public class NullificationPistol : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - public bool ShotType = true; + public bool shotType = true; // true = positive shot, false = negative shot public float mult = 0; public override void SetStaticDefaults() @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Ranged if (player.altFunctionUse == 2) return 1.3f; - if (!ShotType) + if (!shotType) return 1.5f - mult; return 1f - mult; @@ -55,18 +55,18 @@ namespace CalamityMod.Items.Weapons.Ranged if (player.altFunctionUse == 2) { SoundStyle fire = new("CalamityMod/Sounds/Item/DudFire"); - SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = -0.5f + (ShotType ? 0.5f : 0) }, position); + SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = -0.5f + (shotType ? 0.5f : 0) }, position); for (int i = 0; i < 18; i++) { - Dust dust = Dust.NewDustPerfect(position, ShotType ? ModContent.DustType() : ModContent.DustType(), (velocity).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f)); + Dust dust = Dust.NewDustPerfect(position, shotType ? ModContent.DustType() : ModContent.DustType(), (velocity).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.9f, 1.25f); - dust.color = ShotType ? Color.White : (Main.rand.NextBool() ? Color.Orchid : Color.Turquoise); + dust.color = shotType ? Color.White : (Main.rand.NextBool() ? Color.Orchid : Color.Turquoise); } - ShotType = !ShotType; + shotType = !shotType; mult = 0; } - else if (ShotType) + else if (shotType) { for (int i = 0; i < 3; i++) Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage / 3, 0, player.whoAmI, 0, 0, i); @@ -85,7 +85,7 @@ namespace CalamityMod.Items.Weapons.Ranged if (player.altFunctionUse != 2) { SoundStyle fire = new("CalamityMod/Sounds/Item/NullShot"); - SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0f, 0.2f) + (!ShotType ? 0.3f : 0) }, position); + SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = Main.rand.NextFloat(0f, 0.2f) + (!shotType ? 0.3f : 0) }, position); } return false; } diff --git a/Items/Weapons/Ranged/OntologicalDespoiler.cs b/Items/Weapons/Ranged/OntologicalDespoiler.cs new file mode 100644 index 0000000000..5bd8aeef47 --- /dev/null +++ b/Items/Weapons/Ranged/OntologicalDespoiler.cs @@ -0,0 +1,104 @@ +using System.Linq; +using CalamityMod.Dusts; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Ranged; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + [LegacyName("MolecularManipulator")] + public class OntologicalDespoiler : ModItem, ILocalizedModType + { + public static readonly SoundStyle ChargeLV1 = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeLV1") { Volume = 0.6f }; + public static readonly SoundStyle ChargeLV2 = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeLV2") { Volume = 0.6f }; + public static readonly SoundStyle ChargeStart = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeStart") { Volume = 0.6f }; + public static readonly SoundStyle ChargeLoop = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeLoop") { Volume = 0.6f }; + internal static readonly int ChargeLoopSoundFrames = 151; + public static readonly SoundStyle SmallShot = new("CalamityMod/Sounds/Item/ArcNovaDiffuserSmallShot") { PitchVariance = 0.3f }; + public static readonly SoundStyle BigShot = new("CalamityMod/Sounds/Item/ArcNovaDiffuserBigShot") { PitchVariance = 0.3f }; + + public bool shotType = true; // true = positive shot, false = negative shot + public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public override void SetStaticDefaults() + { + ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 88; + Item.height = 34; + Item.damage = 772; + Item.DamageType = DamageClass.Ranged; + Item.useAnimation = Item.useTime = 8; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.channel = true; + Item.useStyle = ItemUseStyleID.Shoot; + Item.knockBack = 6f; + Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + Item.rare = ModContent.RarityType(); + Item.UseSound = null; + Item.autoReuse = false; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 12f; + Item.Calamity().canFirePointBlankShots = true; + } + + public override bool AltFunctionUse(Player player) => true; + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + public override void HoldItem(Player player) + { + if (player.whoAmI != Main.myPlayer) + return; + + // Right-click channeling + player.Calamity().rightClickListener = true; + + if (player.Calamity().mouseRight && CanUseItem(player) && !Main.mapFullscreen && !Main.blockMouse) + { + // Only one out at a time + if (Main.projectile.Any(n => n.active && n.type == Item.shoot && n.owner == player.whoAmI)) + return; + + var source = player.GetSource_ItemUse(player.ActiveItem()); + Projectile holdout = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, Item.shoot, player.ActiveItem().damage, 0f, player.whoAmI, 0, 0, 10 + (shotType ? 5 : 0)); + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + SoundStyle fire = new("CalamityMod/Sounds/Item/DudFire"); + SoundEngine.PlaySound(fire with { Volume = 0.7f, Pitch = -0.5f + (shotType ? 0.5f : 0) }, player.Center); + shotType = !shotType; + } + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + // Only one out at a time + if (Main.projectile.Any(n => n.active && n.type == Item.shoot && n.owner == player.whoAmI)) + return false; + + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, shotType ? 0 : 5); + holdout.velocity = player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter); + return false; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(). + AddIngredient(2). + AddIngredient(). + AddTile(TileID.LunarCraftingStation). + Register(); + } + } +} diff --git a/Items/Weapons/Ranged/OntologicalDespoiler.png b/Items/Weapons/Ranged/OntologicalDespoiler.png new file mode 100644 index 0000000000..ae67daa865 Binary files /dev/null and b/Items/Weapons/Ranged/OntologicalDespoiler.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index ffc863b4bb..ece6d12fb6 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -784,15 +784,6 @@ MineralMortar: { ''' } -MolecularManipulator: { - DisplayName: Molecular Manipulator - Tooltip: - ''' - Fires a fast null bullet that distorts NPC stats - 'Is it nullable or not? Let's find out!' - ''' -} - MonolithBow: { DisplayName: Monolith Bow Tooltip: "" @@ -1448,3 +1439,8 @@ WulfrumBlunderbuss: { [c/83B87E:In fact, it is quite common for a robot to be turned into ammo right after it stops functioning.'] ''' } + +OntologicalDespoiler: { + DisplayName: Ontological Despoiler + Tooltip: "" +} diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 60a0f96207..df3cbdd213 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -140,7 +140,6 @@ NovaChargedShot.DisplayName: Charged Nova Blast NovaShot.DisplayName: Nova Bolt Nuke.DisplayName: Nuke NullShot.DisplayName: Null -NullShot2.DisplayName: Null OpalChargedStrike.DisplayName: Charged Plasma Bolt OpalStrike.DisplayName: Heated Bolt PiercingBullet.DisplayName: Piercing Blow @@ -248,3 +247,6 @@ HellbornProj.DisplayName: Hell-born Gunblast HellbornShell.DisplayName: Hell's Shell NullBurst.DisplayName: Null Burst NullFlash.DisplayName: Null Flash +OntologicalDespoilerBeam.DisplayName: Ontological Despoiler Beam +OntologicalDespoilerGrenade.DisplayName: Ontological Despoiler Grenade +OntologicalDespoilerShot.DisplayName: Ontological Despoiler Shot diff --git a/Particles/DrainLine2.png b/Particles/DrainLine2.png new file mode 100644 index 0000000000..309f0f2ef8 Binary files /dev/null and b/Particles/DrainLine2.png differ diff --git a/Particles/DrainLineBloom2.png b/Particles/DrainLineBloom2.png new file mode 100644 index 0000000000..cce5e51799 Binary files /dev/null and b/Particles/DrainLineBloom2.png differ diff --git a/Projectiles/Ranged/NullShot2.cs b/Projectiles/Ranged/NullShot2.cs deleted file mode 100644 index d24185b9d0..0000000000 --- a/Projectiles/Ranged/NullShot2.cs +++ /dev/null @@ -1,96 +0,0 @@ -using CalamityMod.CalPlayer; -using CalamityMod.NPCs.NormalNPCs; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class NullShot2 : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 6; - Projectile.height = 6; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 120; - Projectile.DamageType = DamageClass.Ranged; - Projectile.extraUpdates = 1; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; - } - - public override void AI() - { - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 3f) - { - for (int num134 = 0; num134 < 10; num134++) - { - float x = Projectile.position.X - Projectile.velocity.X / 10f * (float)num134; - float y = Projectile.position.Y - Projectile.velocity.Y / 10f * (float)num134; - int dust = Dust.NewDust(new Vector2(x, y), 1, 1, DustID.RainbowTorch, 0f, 0f, 0, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1f); - Main.dust[dust].alpha = Projectile.alpha; - Main.dust[dust].position.X = x; - Main.dust[dust].position.Y = y; - Main.dust[dust].velocity *= 0f; - Main.dust[dust].noGravity = true; - } - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - if (target.type == NPCID.TargetDummy) - { - return; - } - - int randAmt = (CalamityPlayer.areThereAnyDamnBosses || CalamityLists.AquaticScourgeIDs.Contains(target.type)) ? 8 : 10; - int nullBuff = Main.rand.Next(randAmt); - if (!target.boss) - { - switch (nullBuff) - { - case 0: - if (target.type != ModContent.NPCType()) - target.damage += 20; - break; - case 1: - target.damage -= 20; - break; - case 2: - target.knockBackResist = 0f; - break; - case 3: - target.knockBackResist = 1f; - break; - case 4: - target.defense += 10; - break; - case 5: - target.defense -= 10; - break; - case 6: - target.velocity.Y = Main.rand.NextBool() ? 30f : -30f; - break; - case 7: - target.velocity.X = Main.rand.NextBool() ? 30f : -30f; - break; - case 8: - target.scale *= 5f; - break; - case 9: - target.scale *= 0.1f; - break; - default: - break; - } - } - } - } -} diff --git a/Projectiles/Ranged/OntoligicalDespoilerGhost.png b/Projectiles/Ranged/OntoligicalDespoilerGhost.png new file mode 100644 index 0000000000..ceab98de55 Binary files /dev/null and b/Projectiles/Ranged/OntoligicalDespoilerGhost.png differ diff --git a/Projectiles/Ranged/OntologicalDespoilerBeam.cs b/Projectiles/Ranged/OntologicalDespoilerBeam.cs new file mode 100644 index 0000000000..519e37fdb7 --- /dev/null +++ b/Projectiles/Ranged/OntologicalDespoilerBeam.cs @@ -0,0 +1,232 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using CalamityMod.NPCs; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class OntologicalDespoilerBeam : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float time => ref Projectile.ai[0]; + public Color baseColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); + public int sineDir = 1; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 25; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() + { + Projectile.width = 28; + Projectile.height = 28; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 400; + Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 4; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + if (time == 0) + { + Projectile.scale = Projectile.ai[1] == 5 ? 2.2f : 1.5f; + sineDir = Main.rand.NextBool() ? 1 : -1; + } + float rate = (Main.GlobalTimeWrappedHourly * 5); + List eColors = new List() + { + Color.Turquoise, + Color.Orchid + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + if (!Main.zenithWorld) + baseColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + if (Projectile.ai[1] == 5 && !Main.zenithWorld) + baseColor = Color.White; + + if (time == 5) + { + for (int i = 0; i < 4; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 5 ? ModContent.DustType() : ModContent.DustType(), (Projectile.velocity * 4).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.2f, 1f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.15f, 1.35f); + dust.color = baseColor; + } + } + if (time > 20) + { + if (Projectile.ai[1] == 5) + { + // Spawn in a helix-style pattern + float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi); + + Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f; + float scale = Main.rand.NextFloat(0.8f, 1.1f); + if (Main.rand.NextBool(2)) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + offset * sineDir, Projectile.ai[1] == 5 ? ModContent.DustType() : ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + dust2.noGravity = true; + dust2.scale = scale; + dust2.color = baseColor; + } + if (Main.rand.NextBool(2)) + { + Dust dust3 = Dust.NewDustPerfect(Projectile.Center - offset * sineDir, /*Projectile.ai[1] == 5 ? ModContent.DustType() : */ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + dust3.noGravity = true; + dust3.scale = scale; + dust3.color = baseColor; + } + } + else if (Main.rand.NextBool(13)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Projectile.ai[1] == 5 ? ModContent.DustType() : ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.05f, 1.65f); + dust.color = baseColor; + } + } + if (time > 13 && time < 34 && Projectile.ai[2] > 0) + { + Projectile.Center += Projectile.velocity.RotatedBy((Projectile.ai[2] == 1 ? MathHelper.PiOver2 : -MathHelper.PiOver2)) * 0.2f; + } + + if (Projectile.ai[1] == 5) + { + NPC targetedNPC = Projectile.Center.ClosestNPCAt(700); + if (targetedNPC != null && time > 30 && Projectile.numHits < 1 && Vector2.Distance(targetedNPC.Center, Projectile.Center) < 700) + { + Vector2 position = targetedNPC.Center; + Vector2 moveToMouse = (position - Projectile.Center).SafeNormalize(Vector2.UnitX); + if (Projectile.velocity.Length() < 8 - (Utils.GetLerpValue(150, 0, Projectile.timeLeft, true) * 2)) + Projectile.velocity += moveToMouse * (0.42f + Utils.GetLerpValue(300, 150, Projectile.timeLeft, true)); + else + Projectile.velocity *= 0.9f; + } + } + else + { + if (Projectile.timeLeft < 100) + { + Projectile.velocity *= 0.96f; + Projectile.scale *= 0.98f; + } + Projectile.timeLeft--; + if (Projectile.timeLeft <= 1) + { + for (int i = 0; i < 4; i++) + { + Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 5).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor); + GeneralParticleHandler.SpawnParticle(orb2); + } + } + } + + time++; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.ai[1] == 5) + { + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 5 ? ModContent.DustType() : ModContent.DustType(), (Projectile.velocity * 3).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.2f, 1f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.15f, 1.45f); + dust.color = baseColor; + } + Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.3f, 0.65f, 13); + GeneralParticleHandler.SpawnParticle(orb); + Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloomRingLayered", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.4f, 0.75f, 13, false); + GeneralParticleHandler.SpawnParticle(orb2); + Particle orb3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.4f, 0.25f, 16, false); + GeneralParticleHandler.SpawnParticle(orb3); + } + else + { + for (int i = 0; i < 3; i++) + { + Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 2).RotatedByRandom(0.1f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor); + GeneralParticleHandler.SpawnParticle(orb2); + } + } + SoundStyle fire = new("CalamityMod/Sounds/Item/NullHit"); + SoundEngine.PlaySound(fire with { Volume = (Projectile.ai[1] == 5 ? 1 : 0.7f), Pitch = Main.rand.NextFloat(0, 0.1f) * (Projectile.ai[1] == 5 ? 3 : 1) }, Projectile.Center); + if (Main.zenithWorld) + { + #region NPC Nullification + int nullBuff = Main.rand.Next(8); + switch (nullBuff) + { + case 0: + if (target.type != ModContent.NPCType()) + target.damage += 10; + break; + case 1: + target.damage -= 10; + break; + case 2: + target.knockBackResist = 0f; + break; + case 3: + target.knockBackResist = 1f; + break; + case 4: + target.defense += 5; + break; + case 5: + target.defense -= 5; + break; + case 6: + target.scale *= 2f; + break; + case 7: + target.scale *= 0.5f; + break; + default: + break; + } + #endregion + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.97f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 18) + return false; + + Asset tex = ModContent.Request("CalamityMod/Particles/DrainLineBloom"); + Asset tex2 = ModContent.Request("CalamityMod/Particles/DrainLine"); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], baseColor with { A = 0 } * 0.35f, 1, tex.Value); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Projectile.ai[1] == 5 ? Color.Black : Color.Lerp(baseColor, Color.White, 0.5f), 1, tex2.Value, true, true); + return false; + } + } +} diff --git a/Projectiles/Ranged/OntologicalDespoilerFlame.png b/Projectiles/Ranged/OntologicalDespoilerFlame.png new file mode 100644 index 0000000000..f17176a2f7 Binary files /dev/null and b/Projectiles/Ranged/OntologicalDespoilerFlame.png differ diff --git a/Projectiles/Ranged/OntologicalDespoilerFlame2.png b/Projectiles/Ranged/OntologicalDespoilerFlame2.png new file mode 100644 index 0000000000..d719aad65a Binary files /dev/null and b/Projectiles/Ranged/OntologicalDespoilerFlame2.png differ diff --git a/Projectiles/Ranged/OntologicalDespoilerFlash.png b/Projectiles/Ranged/OntologicalDespoilerFlash.png new file mode 100644 index 0000000000..3ffbb56a0c Binary files /dev/null and b/Projectiles/Ranged/OntologicalDespoilerFlash.png differ diff --git a/Projectiles/Ranged/OntologicalDespoilerGrenade.cs b/Projectiles/Ranged/OntologicalDespoilerGrenade.cs new file mode 100644 index 0000000000..6ebcd696fa --- /dev/null +++ b/Projectiles/Ranged/OntologicalDespoilerGrenade.cs @@ -0,0 +1,232 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using CalamityMod.NPCs; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class OntologicalDespoilerGrenade : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/OntologicalDespoilerGrenade"; + public ref float time => ref Projectile.ai[0]; + public Color baseColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); + public int sineDir = 1; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 25; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() + { + Projectile.width = 28; + Projectile.height = 28; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 400; + Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 4; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + if (time == 0) + { + Projectile.scale = Projectile.ai[1] == 5 ? 2.2f : 1.5f; + sineDir = Main.rand.NextBool() ? 1 : -1; + } + float rate = (Main.GlobalTimeWrappedHourly * 5); + List eColors = new List() + { + Color.Turquoise, + Color.Orchid + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + if (!Main.zenithWorld) + baseColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + if (Projectile.ai[1] == 5 && !Main.zenithWorld) + baseColor = Color.White; + + if (time == 5) + { + for (int i = 0; i < 4; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 5 ? ModContent.DustType() : ModContent.DustType(), (Projectile.velocity * 4).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.2f, 1f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.15f, 1.35f); + dust.color = baseColor; + } + } + if (time > 20) + { + if (Projectile.ai[1] == 5) + { + // Spawn in a helix-style pattern + float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi); + + Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 16f; + float scale = Main.rand.NextFloat(0.8f, 1.1f); + if (Main.rand.NextBool(2)) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + offset * sineDir, Projectile.ai[1] == 5 ? ModContent.DustType() : ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + dust2.noGravity = true; + dust2.scale = scale; + dust2.color = baseColor; + } + if (Main.rand.NextBool(2)) + { + Dust dust3 = Dust.NewDustPerfect(Projectile.Center - offset * sineDir, /*Projectile.ai[1] == 5 ? ModContent.DustType() : */ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + dust3.noGravity = true; + dust3.scale = scale; + dust3.color = baseColor; + } + } + else if (Main.rand.NextBool(13)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Projectile.ai[1] == 5 ? ModContent.DustType() : ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.05f, 1.65f); + dust.color = baseColor; + } + } + if (time > 13 && time < 34 && Projectile.ai[2] > 0) + { + Projectile.Center += Projectile.velocity.RotatedBy((Projectile.ai[2] == 1 ? MathHelper.PiOver2 : -MathHelper.PiOver2)) * 0.2f; + } + + if (Projectile.ai[1] == 5) + { + NPC targetedNPC = Projectile.Center.ClosestNPCAt(700); + if (targetedNPC != null && time > 30 && Projectile.numHits < 1 && Vector2.Distance(targetedNPC.Center, Projectile.Center) < 700) + { + Vector2 position = targetedNPC.Center; + Vector2 moveToMouse = (position - Projectile.Center).SafeNormalize(Vector2.UnitX); + if (Projectile.velocity.Length() < 8 - (Utils.GetLerpValue(150, 0, Projectile.timeLeft, true) * 2)) + Projectile.velocity += moveToMouse * (0.42f + Utils.GetLerpValue(300, 150, Projectile.timeLeft, true)); + else + Projectile.velocity *= 0.9f; + } + } + else + { + if (Projectile.timeLeft < 100) + { + Projectile.velocity *= 0.96f; + Projectile.scale *= 0.98f; + } + Projectile.timeLeft--; + if (Projectile.timeLeft <= 1) + { + for (int i = 0; i < 4; i++) + { + Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 5).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor); + GeneralParticleHandler.SpawnParticle(orb2); + } + } + } + + time++; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.ai[1] == 5) + { + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Projectile.ai[1] == 5 ? ModContent.DustType() : ModContent.DustType(), (Projectile.velocity * 3).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.2f, 1f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.15f, 1.45f); + dust.color = baseColor; + } + Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.3f, 0.65f, 13); + GeneralParticleHandler.SpawnParticle(orb); + Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloomRingLayered", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.4f, 0.75f, 13, false); + GeneralParticleHandler.SpawnParticle(orb2); + Particle orb3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.4f, 0.25f, 16, false); + GeneralParticleHandler.SpawnParticle(orb3); + } + else + { + for (int i = 0; i < 3; i++) + { + Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 2).RotatedByRandom(0.1f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor); + GeneralParticleHandler.SpawnParticle(orb2); + } + } + SoundStyle fire = new("CalamityMod/Sounds/Item/NullHit"); + SoundEngine.PlaySound(fire with { Volume = (Projectile.ai[1] == 5 ? 1 : 0.7f), Pitch = Main.rand.NextFloat(0, 0.1f) * (Projectile.ai[1] == 5 ? 3 : 1) }, Projectile.Center); + if (Main.zenithWorld) + { + #region NPC Nullification + int nullBuff = Main.rand.Next(8); + switch (nullBuff) + { + case 0: + if (target.type != ModContent.NPCType()) + target.damage += 10; + break; + case 1: + target.damage -= 10; + break; + case 2: + target.knockBackResist = 0f; + break; + case 3: + target.knockBackResist = 1f; + break; + case 4: + target.defense += 5; + break; + case 5: + target.defense -= 5; + break; + case 6: + target.scale *= 2f; + break; + case 7: + target.scale *= 0.5f; + break; + default: + break; + } + #endregion + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.97f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 18) + return false; + + Asset tex = ModContent.Request("CalamityMod/Particles/DrainLineBloom"); + Asset tex2 = ModContent.Request("CalamityMod/Particles/DrainLine"); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], baseColor with { A = 0 } * 0.35f, 1, tex.Value); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Projectile.ai[1] == 5 ? Color.Black : Color.Lerp(baseColor, Color.White, 0.5f), 1, tex2.Value, true, true); + return false; + } + } +} diff --git a/Projectiles/Ranged/OntologicalDespoilerGrenade.png b/Projectiles/Ranged/OntologicalDespoilerGrenade.png new file mode 100644 index 0000000000..fa6d3b761d Binary files /dev/null and b/Projectiles/Ranged/OntologicalDespoilerGrenade.png differ diff --git a/Projectiles/Ranged/OntologicalDespoilerHoldout.cs b/Projectiles/Ranged/OntologicalDespoilerHoldout.cs new file mode 100644 index 0000000000..a4d5da785b --- /dev/null +++ b/Projectiles/Ranged/OntologicalDespoilerHoldout.cs @@ -0,0 +1,451 @@ +using System; +using System.Collections.Generic; +using System.Reflection.Metadata; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class OntologicalDespoilerHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 29f; + public override float OffsetXUpwards => -8f; + public override float BaseOffsetY => -10f; + public override float OffsetYDownwards => 8f; + public override float RecoilResolveSpeed => 0.5f; + public override Vector2 GunTipPosition => Projectile.Center + (Projectile.velocity * 45).RotatedBy(0.18f * Projectile.direction); + + public int FramesPerLoad = 9; + public int MaxLoadableShots = 23; + public float BulletSpeed = 6.5f; + public SlotId OntologicalChargeSlot; + public int Time = 0; + + public ref float CurrentChargingFrames => ref Projectile.ai[0]; + public float ShotsLoaded = 1; + public Color baseColor = Color.White; + + public Color color1 = Color.DarkMagenta; + public Color color2 = Color.DarkOrchid; + public Color color3 = Color.Purple; + public Color color4 = Color.BlueViolet; + + public bool hasBegunFiring = false; + public bool Positive => Projectile.ai[2] == 0; + public ref float ShootRecoilTimer => ref Projectile.ai[1]; // Dual functions for rapid fire shooting cooldown and recoil + + public int AftershotCooldownFrames = 8; + public int Charge1Frames = 156; + public int Charge2Frames = 308; + + public int fireFrameCounter = 0; + public int fireFrame = 0; + public int flashFrameCounter = 0; + public int flashFrame = 0; + public bool showFlash = false; + public Vector2 flashPos; + public float flashRot; + public Vector2 voidPlacement; + public bool ChargeLV1 => CurrentChargingFrames >= Charge1Frames; + public bool ChargeLV2 => CurrentChargingFrames >= Charge2Frames; + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 7; + } + public override void KillHoldoutLogic() + { + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + Projectile.Kill(); + } + + public override void HoldoutAI() + { + if (SoundEngine.TryGetActiveSound(OntologicalChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying) + ChargeSound.Position = Projectile.Center; + + float rate = (Main.GlobalTimeWrappedHourly * 15); + List eColors = new List() + { + color1, + color2, + color3, + color4 + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + baseColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + if (!Positive) + baseColor = Color.White; + + Projectile.frameCounter++; + if (Projectile.frameCounter > 1) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 5) + { + Projectile.frame = 0; + } + + fireFrameCounter++; + if (fireFrameCounter > 1) + { + fireFrame++; + fireFrameCounter = 0; + } + if (fireFrame > 5) + fireFrame = 0; + + if (showFlash) + { + flashFrameCounter++; + if (flashFrameCounter > (flashFrame == 2 ? 7 : 1)) + { + flashFrame++; + flashFrameCounter = 0; + } + if (flashFrame > 6) + showFlash = false; + } + if (Time % 2 == 0) + voidPlacement = Main.rand.NextVector2Circular(10.5f, 10.5f); + if (Projectile.ai[2] >= 10) // Changing Mode + { + Owner.Calamity().despoilerNerf = false; + Projectile.frame = 6; + fireFrame = 6; + ShotsLoaded = 0; + if (Time == 0) + { + for (int i = 0; i < 18; i++) + { + Color useColor = Main.rand.Next(4) switch + { + 0 => color1, + 1 => color2, + 2 => color3, + _ => color4, + }; + Dust dust = Dust.NewDustPerfect(Owner.Center, Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType(), new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 1f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.9f, 1.25f); + dust.color = Projectile.ai[2] == 15 ? Color.White : useColor; + } + Projectile.timeLeft = AftershotCooldownFrames * 2; + OffsetLengthFromArm = 25f; + } + } + + // Fire if the owner stops channeling or otherwise cannot use the weapon. + if (Owner.CantUseHoldout() || Projectile.ai[2] >= 10) + { + if (Projectile.ai[2] < 10) + Owner.Calamity().despoilerNerf = true; + hasBegunFiring = true; + KeepRefreshingLifetime = false; + + // Big Shot mode + if (ChargeLV2) + { + if (ShotsLoaded > 0) + { + // Set lifespan to double of remaining cooldown so that it can finish the recoil animation + Projectile.timeLeft = AftershotCooldownFrames * 2; + + ChargeSound?.Stop(); + + if (Positive) + { + + } + else + { + + } + SoundEngine.PlaySound(OntologicalDespoiler.BigShot, Projectile.position); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; + int charge2Damage = Projectile.damage * 20; + float charge2KB = Projectile.knockBack * 3f; + //Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), charge2Damage, charge2KB, Projectile.owner); + Owner.Calamity().GeneralScreenShakePower = 9.5f; + flashPos = GunTipPosition + Projectile.velocity * 90; + flashRot = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + showFlash = true; + for (int i = 0; i < 20; i++) + { + Color useColor = Main.rand.Next(4) switch + { + 0 => color1, + 1 => color2, + 2 => color3, + _ => color4, + }; + float rand = Main.rand.NextFloat(0, 2.5f); + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, ModContent.DustType(), shootVelocity.RotatedByRandom(0.12f + rand * 0.2f) * (Main.rand.NextFloat(2.5f, 6.3f) - rand)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.55f, 1.85f); + dust.color = Positive ? useColor : baseColor; + } + + ShotsLoaded = 0; + ShootRecoilTimer = 34f; + OffsetLengthFromArm -= 35f; + } + // Retracting recoil + else if (ShootRecoilTimer > 0) + ShootRecoilTimer -= 2; + } + // Rapid Fire mode + else if (ShotsLoaded > 0) + { + // While bullets are remaining, refresh the lifespan; it will not refresh again after bullets run out + Projectile.timeLeft = AftershotCooldownFrames; + + // Retract recoil & shoot faster if charged + ShootRecoilTimer -= ChargeLV1 ? 2.5f : 2f; + + if (ShootRecoilTimer <= 0f) + { + ChargeSound?.Stop(); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; + Vector2 fireVec = shootVelocity * Main.rand.NextFloat(0.9f, 1.1f); + if (Positive) + { + for (int i = 0; i < 3; i++) + { + float angle = i == 0 ? -0.25f : i == 2 ? 0.25f : 0; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec.RotatedBy(angle) * (1 - Math.Abs(angle * 0.4f)), ModContent.ProjectileType(), Projectile.damage / 3, Projectile.knockBack, Projectile.owner, 0, 0, i); + } + } + else + { + for (int i = 0; i < 2; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, fireVec.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.8f, 1f), ModContent.ProjectileType(), Projectile.damage / 3, Projectile.knockBack, Projectile.owner, 0, 0, 5); + } + } + + SoundEngine.PlaySound(OntologicalDespoiler.SmallShot, Projectile.position); + for (int i = 0; i < 3; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 15, !Positive ? ModContent.DustType() : ModContent.DustType(), shootVelocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.3f, 2.3f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.15f, 1.35f); + dust.color = baseColor; + } + + ShotsLoaded -= (Positive ? 2 : 1); + ShootRecoilTimer = Positive ? 16 : 12f; + OffsetLengthFromArm -= 3.2f; + } + } + // Retracting any remaining recoil + else if (ShootRecoilTimer > 0) + ShootRecoilTimer -= 2; + } + else + { + // Loads shots until maxed out + if (ShotsLoaded < MaxLoadableShots && CurrentChargingFrames % FramesPerLoad == 0) + ShotsLoaded++; + + CurrentChargingFrames += 2 * (Owner.Calamity().despoilerNerf ? 0.5f : 1); + + // Sounds + if (ChargeLV1) + { + // Pulse sounds play independently of the loop + if (CurrentChargingFrames == Charge2Frames) + SoundEngine.PlaySound(OntologicalDespoiler.ChargeLV2, Projectile.Center); + else if (CurrentChargingFrames == Charge1Frames) + { + SoundEngine.PlaySound(OntologicalDespoiler.ChargeLV1, Projectile.Center); + ShotsLoaded = MaxLoadableShots; + } + + if ((CurrentChargingFrames - Charge1Frames) % (OntologicalDespoiler.ChargeLoopSoundFrames * 2) == 0) + OntologicalChargeSlot = SoundEngine.PlaySound(OntologicalDespoiler.ChargeLoop, Projectile.Center); + } + else if (CurrentChargingFrames == 10) + OntologicalChargeSlot = SoundEngine.PlaySound(OntologicalDespoiler.ChargeStart, Projectile.Center); + + // Charge-up visuals + if (CurrentChargingFrames >= 10 && (Positive || (!Positive && !ChargeLV2))) + { + float particleScale = MathHelper.Clamp(CurrentChargingFrames, 0f, Charge2Frames); + for (int i = 0; i < (ChargeLV2 ? 3 : ChargeLV1 ? 2 : 1); i++) + { + //SparkParticle spark2 = new SparkParticle((GunTipPosition - Projectile.velocity * 4) + Main.rand.NextVector2Circular(12, 12), -Projectile.velocity * Main.rand.NextFloat(16.1f, 30.8f), false, Main.rand.Next(2, 7), Main.rand.NextFloat(particleScale / 350f, particleScale / 270f), baseColor); + //GeneralParticleHandler.SpawnParticle(spark2); + Vector2 dustVel = -Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(1.1f, 15.8f); + Vector2 addedPlace = Positive ? Vector2.Zero : dustVel * 3; + Dust dust = Dust.NewDustPerfect(GunTipPosition + (Positive ? Vector2.Zero : (dustVel * 15 * Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true))), !Positive ? ModContent.DustType() : ChargeLV1 ? Main.rand.NextBool((int)(50 * Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true) + 1)) ? ModContent.DustType() : ModContent.DustType() : ModContent.DustType(), dustVel - addedPlace * Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.5f, 1.25f) * Utils.GetLerpValue(0, Charge1Frames, CurrentChargingFrames, true); + dust.color = baseColor; + } + //Particle orb2 = new GenericBloom(GunTipPosition, Projectile.velocity, Color.Black * 0.5f, (particleScale / 350f) * Main.rand.NextFloat(0.9f, 1.1f), 2, false, false); + //GeneralParticleHandler.SpawnParticle(orb2); + Particle orb = new GenericBloom(GunTipPosition, Projectile.velocity, Positive ? Color.Lerp(Color.White, Color.Black, Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true)) : Color.Black * Utils.GetLerpValue(0, Charge1Frames, CurrentChargingFrames, true), (particleScale / 400f) * Main.rand.NextFloat(0.9f, 1.1f), 2, false, false); + GeneralParticleHandler.SpawnParticle(orb); + + float strength = particleScale / 45f; + Vector3 DustLight = baseColor.ToVector3() * 0.2f; + Lighting.AddLight(GunTipPosition, DustLight * strength); + } + if (ChargeLV2 && !Positive) + { + for (int i = 0; i < 3; i++) + { + Particle orb = new CustomSpark(GunTipPosition, Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(1.1f, 15.8f), "CalamityMod/Particles/PearlParticleGlow", false, 3, Main.rand.NextFloat(1.8f, 1.9f), Color.Black, new Vector2(0.3f, 1.3f), false, false); + GeneralParticleHandler.SpawnParticle(orb); + Vector2 dustVel = -Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(1.1f, 15.8f); + Dust dust = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType(), dustVel); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.5f, 1.25f) * Utils.GetLerpValue(0, Charge1Frames, CurrentChargingFrames, true); + dust.color = baseColor; + } + } + + // Full charge dusts + if (CurrentChargingFrames == Charge1Frames) + { + for (int i = 0; i < 16; i++) + { + Color useColor = Main.rand.Next(4) switch + { + 0 => color1, + 1 => color2, + 2 => color3, + _ => color4, + }; + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType()); + chargefull.velocity = (MathHelper.TwoPi * i / 16f).ToRotationVector2() * 16f * (i % 2 == 0 ? 0.7f : 1); + chargefull.scale = Main.rand.NextFloat(1.1f, 1.3f); + chargefull.noGravity = true; + chargefull.color = Positive ? useColor : baseColor; + } + } + if (CurrentChargingFrames == Charge2Frames) + { + for (int i = 0; i < 25; i++) + { + Color useColor = Main.rand.Next(4) switch + { + 0 => color1, + 1 => color2, + 2 => color3, + _ => color4, + }; + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, ModContent.DustType()); + chargefull.velocity = (MathHelper.TwoPi * i / 25f).ToRotationVector2() * 22f * (i % 2 == 0 ? 0.7f : 1); + chargefull.scale = Main.rand.NextFloat(1.45f, 1.55f); + chargefull.noGravity = true; + chargefull.color = Positive ? useColor : baseColor; + } + } + } + if (!hasBegunFiring) + { + Projectile.frame = 6; + fireFrame = 6; + } + else + { + Lighting.AddLight(Projectile.Center, baseColor.ToVector3() * 0.75f); + } + Time++; + } + + public override void OnKill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(OntologicalChargeSlot, out var ChargeSound)) + ChargeSound?.Stop(); + } + + public override bool PreDraw(ref Color lightColor) + { + if (Time < 3) + return false; + + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Ranged/OntologicalDespoilerHoldout").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 rotationPoint = frame.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Texture2D fireTexture = ModContent.Request("CalamityMod/Projectiles/Ranged/OntologicalDespoilerFlame").Value; + Texture2D fireTexture2 = ModContent.Request("CalamityMod/Projectiles/Ranged/OntologicalDespoilerFlame2").Value; + Rectangle frame2 = fireTexture.Frame(1, 7, 0, fireFrame); + Vector2 rotationPoint2 = frame2.Size() * 0.5f; + + Texture2D flashTexture = ModContent.Request("CalamityMod/Projectiles/Ranged/OntologicalDespoilerFlash").Value; + Rectangle frame3 = fireTexture.Frame(1, 6, 0, flashFrame); + Vector2 rotationPoint3 = frame3.Size() * 0.5f; + + Texture2D rechargeTexture = ModContent.Request("CalamityMod/Particles/FlameExplosion").Value; + Texture2D rechargeTexture2 = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + // Glow Orb + float randSize = Main.rand.NextFloat(0.9f, 1.1f); + if (!hasBegunFiring) + { + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(rechargeTexture, GunTipPosition - Main.screenPosition, null, baseColor with { A = 0 }, Projectile.rotation + Main.rand.NextFloat(-30, 30), rechargeTexture.Size() * 0.5f, 0.028f * Utils.GetLerpValue(0, Charge2Frames, CurrentChargingFrames, true) * randSize, SpriteEffects.None, 0); + Main.EntitySpriteDraw(rechargeTexture2, GunTipPosition - Main.screenPosition, null, Positive ? Color.Lerp(Color.White, Color.Black, Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true)) : Color.Black, Projectile.rotation + Main.rand.NextFloat(-30, 30), rechargeTexture2.Size() * 0.5f, 0.58f * Utils.GetLerpValue(0, Charge2Frames, CurrentChargingFrames, true) * randSize, SpriteEffects.None, 0); + } + if (!Owner.CantUseHoldout()) + { + float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, Charge2Frames); + drawPosition += Main.rand.NextVector2Circular(rumble / 120f, rumble / 120f); + } + + if (ChargeLV1 && !Positive && !hasBegunFiring) + { + for (int i = 0; i < 2; i++) + { + Vector2 placement = drawPosition + voidPlacement; + Main.EntitySpriteDraw(texture, placement, frame, baseColor with { A = 0 } * 0.3f * Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true), drawRotation, rotationPoint, new Vector2(Main.rand.NextFloat(0.7f, 1f), Main.rand.NextFloat(0.8f, 1.2f)) * Projectile.scale * Owner.gravDir * 1.1f, flipSprite); + Main.EntitySpriteDraw(texture, placement, frame, Color.Black * Utils.GetLerpValue(Charge1Frames, Charge2Frames, CurrentChargingFrames, true), drawRotation, rotationPoint, new Vector2(Main.rand.NextFloat(0.7f, 1f), Main.rand.NextFloat(0.6f, 1f)) * Projectile.scale * Owner.gravDir, flipSprite); + } + } + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + if (Projectile.frame < 6) + { + if (Positive && false) + Main.EntitySpriteDraw(fireTexture, drawPosition, frame2, baseColor with { A = 0 }, drawRotation, rotationPoint2, Projectile.scale * Owner.gravDir, flipSprite); + else + { + for (int i = 0; i< 4; i++) + Main.EntitySpriteDraw(fireTexture, drawPosition + Main.rand.NextVector2Circular(4.5f, 4.5f), frame2, baseColor with { A = 0 } * 0.3f, drawRotation, rotationPoint2, Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(Positive ? fireTexture : fireTexture2, drawPosition, frame2, Positive ? baseColor with { A = 0 } : baseColor, drawRotation, rotationPoint2, Projectile.scale * Owner.gravDir, flipSprite); + } + } + if (showFlash) + { + for (int i = 0; i < 4; i++) + Main.EntitySpriteDraw(flashTexture, flashPos - Main.screenPosition + Main.rand.NextVector2Circular(4.5f, 4.5f), frame3, baseColor with { A = 0 } * 0.3f, flashRot, rotationPoint3, new Vector2(3, 0.8f) * Projectile.scale * Owner.gravDir, flipSprite); + Main.EntitySpriteDraw(flashTexture, flashPos - Main.screenPosition, frame3, Color.Black, flashRot, rotationPoint3, new Vector2(3, 0.8f) * Projectile.scale * Owner.gravDir, flipSprite); + } + + return false; + } + } +} diff --git a/Projectiles/Ranged/OntologicalDespoilerHoldout.png b/Projectiles/Ranged/OntologicalDespoilerHoldout.png new file mode 100644 index 0000000000..693bdd24b7 Binary files /dev/null and b/Projectiles/Ranged/OntologicalDespoilerHoldout.png differ diff --git a/Projectiles/Ranged/OntologicalDespoilerShot.cs b/Projectiles/Ranged/OntologicalDespoilerShot.cs new file mode 100644 index 0000000000..a15be72b96 --- /dev/null +++ b/Projectiles/Ranged/OntologicalDespoilerShot.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.Generic; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using CalamityMod.NPCs; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.Projectiles.Rogue.FinalDawnFlame; + +namespace CalamityMod.Projectiles.Ranged +{ + public class OntologicalDespoilerShot : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/OntologicalDespoilerShot"; + public ref float time => ref Projectile.ai[0]; + public Color baseColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); + public int sineDir = 1; + public int zagRate = 55; + + public Color color1 = Color.DarkMagenta; + public Color color2 = Color.DarkOrchid; + public Color color3 = Color.Purple; + public Color color4 = Color.BlueViolet; + public bool Positive => Projectile.ai[2] < 5; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 25; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() + { + Projectile.width = 28; + Projectile.height = 28; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 600; + Projectile.DamageType = DamageClass.Ranged; + Projectile.extraUpdates = 4; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation(); + + Projectile.frameCounter++; + if (Projectile.frameCounter > 1) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 5) + { + Projectile.frame = 0; + } + + if (time == 0) + { + Projectile.scale = 1f; + sineDir = Main.rand.NextBool() ? 1 : -1; + Projectile.frame = Main.rand.Next(0, 6 + 1); + zagRate = Main.rand.Next(55, 70 + 1); + if (!Positive) + Projectile.penetrate = 1; + } + float rate = (Main.GlobalTimeWrappedHourly * 15); + List eColors = new List() + { + color1, + color2, + color3, + color4 + }; + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + baseColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + if (!Positive) + baseColor = Color.White; + + if (time > 20) + { + if (!Positive) + { + // Spawn in a helix-style pattern + float sine = (float)Math.Sin(Projectile.timeLeft * 0.575f / MathHelper.Pi); + + Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 8f; + float scale = Main.rand.NextFloat(0.3f, 0.4f); + if (true) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + offset * sineDir, ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + dust2.noGravity = true; + dust2.scale = scale; + dust2.color = baseColor; + //Dust dust3 = Dust.NewDustPerfect(Projectile.Center - offset * sineDir, ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.8f)); + //dust3.noGravity = true; + //dust3.scale = scale; + //dust3.color = baseColor; + } + } + else + { + if (Main.rand.NextBool(21)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), ModContent.DustType(), -Projectile.velocity * Main.rand.NextFloat(0.3f, 1.8f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.8f, 1.15f); + dust.color = baseColor; + } + if ((time < 15 || time % 25 <= 15) && Projectile.ai[2] != 1) + { + Projectile.velocity = Projectile.velocity.RotatedBy(0.5f / 15f * (Projectile.ai[2] == 2 ? 1 : -1)); + if (time % 25 == 0 || time == 15) + Projectile.ai[2] = (Projectile.ai[2] == 2 ? 0 : 2); + } + } + } + + if (!Positive) + { + NPC targetedNPC = Projectile.Center.ClosestNPCAt(700); + if (targetedNPC != null && time > 30 && Projectile.numHits < 1 && Vector2.Distance(targetedNPC.Center, Projectile.Center) < 700) + { + Vector2 position = targetedNPC.Center; + Vector2 moveToMouse = (position - Projectile.Center).SafeNormalize(Vector2.UnitX); + if (Projectile.velocity.Length() < 8 - (Utils.GetLerpValue(350, 0, Projectile.timeLeft, true) * 2)) + Projectile.velocity += moveToMouse * (0.42f + Utils.GetLerpValue(500, 350, Projectile.timeLeft, true)); + else + Projectile.velocity *= 0.9f; + } + } + else + { + if (Projectile.timeLeft < 100) + { + Projectile.velocity *= 0.96f; + Projectile.scale *= 0.98f; + } + Projectile.timeLeft--; + if (Projectile.timeLeft <= 1) + { + for (int i = 0; i < 2; i++) + { + Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 5).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor); + GeneralParticleHandler.SpawnParticle(orb2); + } + } + } + + time++; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (!Positive) + { + for (int i = 0; i < 3; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, !Positive ? ModContent.DustType() : ModContent.DustType(), (Projectile.velocity * 3).RotatedByRandom(0.7f) * Main.rand.NextFloat(0.2f, 1f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.15f, 1.45f); + dust.color = baseColor; + } + Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.15f, 0.65f, 8); + GeneralParticleHandler.SpawnParticle(orb); + Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloomRingLayered", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.2f, 0.75f, 8, false); + GeneralParticleHandler.SpawnParticle(orb2); + Particle orb3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/SmallBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0.4f, 0.05f, 9, false); + GeneralParticleHandler.SpawnParticle(orb3); + } + else + { + for (int i = 0; i < 3; i++) + { + Particle orb2 = new LineParticle(Projectile.Center, (Projectile.velocity * 4).RotatedByRandom(0.15f) * Main.rand.NextFloat(0.1f, 1f), false, Main.rand.Next(20, 28 + 1), Main.rand.NextFloat(0.6f, 1.3f), baseColor); + GeneralParticleHandler.SpawnParticle(orb2); + } + } + SoundStyle fire = new("CalamityMod/Sounds/Item/NullHit"); + SoundEngine.PlaySound(fire with { Volume = (!Positive ? 1 : 0.7f), Pitch = Main.rand.NextFloat(0, 0.1f) * (!Positive ? 3 : 1) }, Projectile.Center); + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.9f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + public override bool PreDraw(ref Color lightColor) + { + if (time < 2) + return false; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation; + + Asset tex = ModContent.Request("CalamityMod/Particles/DrainLineBloom2"); + Asset tex2 = ModContent.Request("CalamityMod/Particles/DrainLine2"); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], baseColor with { A = 0 } * 0.8f, 1, tex.Value); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Positive ? Color.Lerp(Color.White, baseColor, MathHelper.Clamp(Utils.GetLerpValue(50, 175, time, true), 0, 0.5f)) with { A = 0 } : Color.Black, 1, tex2.Value, true, true); + + Asset tex3 = ModContent.Request("CalamityMod/Projectiles/Ranged/OntologicalDespoilerShot"); + Asset tex4 = ModContent.Request("CalamityMod/Projectiles/Ranged/OntologicalDespoilerShot2"); + Rectangle frame = tex3.Frame(1, 6, 0, Projectile.frame); + Vector2 rotationPoint = frame.Size() * 0.5f; + Main.EntitySpriteDraw(Positive ? tex4.Value : tex3.Value, drawPosition, frame, baseColor with { A = 0 }, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); + + return false; + } + } +} diff --git a/Projectiles/Ranged/OntologicalDespoilerShot.png b/Projectiles/Ranged/OntologicalDespoilerShot.png new file mode 100644 index 0000000000..897479fad9 Binary files /dev/null and b/Projectiles/Ranged/OntologicalDespoilerShot.png differ diff --git a/Projectiles/Ranged/OntologicalDespoilerShot2.png b/Projectiles/Ranged/OntologicalDespoilerShot2.png new file mode 100644 index 0000000000..8103eba981 Binary files /dev/null and b/Projectiles/Ranged/OntologicalDespoilerShot2.png differ