diff --git a/Buffs/DamageOverTime/Laceration.cs b/Buffs/DamageOverTime/Laceration.cs new file mode 100644 index 0000000000..621b51dfe4 --- /dev/null +++ b/Buffs/DamageOverTime/Laceration.cs @@ -0,0 +1,74 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.DamageOverTime +{ + public class Laceration : ModBuff + { + public override void SetStaticDefaults() + { + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + BuffID.Sets.LongerExpertDebuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().laceration = true; + } + + public override void Update(NPC npc, ref int buffIndex) + { + if (npc.Calamity().laceration < npc.buffTime[buffIndex]) + npc.Calamity().laceration = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; + } + internal static void DrawEffects(PlayerDrawSet drawInfo) + { + Player player = drawInfo.drawPlayer; + var modPlayer = player.Calamity(); + + if (Main.rand.NextBool()) + { + Vector2 randVel = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f); + Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, 5, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.6f, 0.9f)); + dust.noGravity = false; + Particle spark = new AltSparkParticle(modPlayer.RandomDebuffVisualSpot, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), Color.DarkRed * 0.5f); + GeneralParticleHandler.SpawnParticle(spark); + } + if (Main.rand.NextBool(8)) + { + Particle spark = new GlowOrbParticle(modPlayer.RandomDebuffVisualSpot, new Vector2(0, 4) * Main.rand.NextFloat(0.5f, 0.7f), true, 16, Main.rand.NextFloat(0.55f, 0.8f), Color.DarkRed * 0.8f, false, false, false); + GeneralParticleHandler.SpawnParticle(spark); + } + } + + internal static void DrawEffects(NPC npc, ref Color drawColor) + { + Vector2 npcSize = npc.Center + new Vector2(Main.rand.NextFloat(-npc.width / 2, npc.width / 2), Main.rand.NextFloat(-npc.height / 2, npc.height / 2)); + Vector2 randVel = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f); + if (Main.rand.NextBool(3)) + { + Particle spark = new AltSparkParticle(npcSize, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), Color.DarkRed * 0.5f); + GeneralParticleHandler.SpawnParticle(spark); + } + else + { + Dust dust = Dust.NewDustPerfect(npcSize, 5, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.2f, 0.6f)); + dust.noGravity = false; + } + if (Main.rand.NextBool(8)) + { + Particle spark = new GlowOrbParticle(npcSize, new Vector2(0, 4) * Main.rand.NextFloat(0.5f, 0.7f), true, 16, Main.rand.NextFloat(0.55f, 0.8f), Color.DarkRed * 0.8f, false, false, false); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } +} diff --git a/Buffs/DamageOverTime/Laceration.png b/Buffs/DamageOverTime/Laceration.png new file mode 100644 index 0000000000..5a577ad3dc Binary files /dev/null and b/Buffs/DamageOverTime/Laceration.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index c8bd2f55cf..9137d7d2eb 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -31,6 +31,7 @@ using CalamityMod.Items.TreasureBags.MiscGrabBags; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs; @@ -880,6 +881,7 @@ namespace CalamityMod.CalPlayer public bool bBlood = false; public bool brainRot = false; public bool heavybleeding = false; + public bool laceration = false; public bool elementalMix = false; public bool icarusFolly = false; public bool weakPetrification = false; @@ -1935,6 +1937,7 @@ namespace CalamityMod.CalPlayer bBlood = false; brainRot = false; heavybleeding = false; + laceration = false; elementalMix = false; icarusFolly = false; vHex = false; @@ -2358,6 +2361,7 @@ namespace CalamityMod.CalPlayer bBlood = false; brainRot = false; heavybleeding = false; + laceration = false; elementalMix = false; icarusFolly = false; vHex = false; @@ -3079,16 +3083,16 @@ namespace CalamityMod.CalPlayer //Right click dash on Speed Blaster if (sBlasterDashActivated == true) { - if ((Player.controlUp || Player.controlDown || Player.controlLeft || Player.controlRight) && !Player.pulley && Player.grappling[0] == -1 && !Player.tongued && !Player.mount.Active && Player.HasCooldown(Cooldowns.SpeedBlasterBoost.ID) && Player.dashDelay == 0) + if ((Player.controlUp || Player.controlDown || Player.controlLeft || Player.controlRight) && !Player.pulley && Player.grappling[0] == -1 && !Player.tongued && !Player.mount.Active && (Player.HasCooldown(SpeedBlasterBoost.ID) || Player.HasCooldown(SuperradiantSawBoost.ID)) && Player.dashDelay == 0) { SpeedBlasterDashStarted = true; } sBlasterDashActivated = false; } - if (Player.Calamity().SpeedBlasterDashStarted || (Player.dashDelay != 0 && Player.Calamity().LastUsedDashID == SpeedBlasterDash.ID)) + if (Player.Calamity().SpeedBlasterDashStarted || (Player.dashDelay != 0 && (Player.Calamity().LastUsedDashID == SpeedBlasterDash.ID || Player.Calamity().LastUsedDashID == SuperradiantSawDash.ID))) { - Player.Calamity().DeferredDashID = SpeedBlasterDash.ID; + Player.Calamity().DeferredDashID = Player.ActiveItem().type == ModContent.ItemType() ? SuperradiantSawDash.ID : SpeedBlasterDash.ID; Player.dash = 0; } @@ -4284,20 +4288,8 @@ namespace CalamityMod.CalPlayer if (weakPetrification) WeakPetrification(); - // Disable vanilla dashes during god slayer dash - if (godSlayerDashHotKeyPressed) - { - // Set the player to have no registered vanilla dashes. - Player.dashType = 0; - - // Prevent the possibility of Shield of Cthulhu invulnerability exploits. - Player.eocHit = -1; - if (Player.eocDash != 0) - Player.eocDash = 0; - } - - // Disable vanilla dashes during god slayer dash - if (SpeedBlasterDashStarted) + // Disable vanilla dashes during God Slayer or Speed Blaster dashes + if (godSlayerDashHotKeyPressed || SpeedBlasterDashStarted) { // Set the player to have no registered vanilla dashes. Player.dashType = 0; diff --git a/CalPlayer/CalamityPlayerDashEffects.cs b/CalPlayer/CalamityPlayerDashEffects.cs index e66c90baa5..da590b45e9 100644 --- a/CalPlayer/CalamityPlayerDashEffects.cs +++ b/CalPlayer/CalamityPlayerDashEffects.cs @@ -13,8 +13,7 @@ namespace CalamityMod.CalPlayer { public partial class CalamityPlayer : ModPlayer { - public int VerticalGodslayerDashTimer; - public int VerticalSpeedBlasterDashTimer; + public int VerticalOmnidashTimer; private string dashID; //private backing variable @@ -104,16 +103,9 @@ namespace CalamityMod.CalPlayer } } - if (Player.dashDelay > 0) //Speed Blaster - { - VerticalSpeedBlasterDashTimer = 0; - LastUsedDashID = string.Empty; - return; - } - if (Player.dashDelay > 0) { - VerticalGodslayerDashTimer = 0; + VerticalOmnidashTimer = 0; LastUsedDashID = string.Empty; return; } @@ -137,21 +129,10 @@ namespace CalamityMod.CalPlayer // Handle mid-dash effects. UsedDash.MidDashEffects(Player, ref dashSpeed, ref dashSpeedDecelerationFactor, ref runSpeedDecelerationFactor); - if (UsedDash.IsOmnidirectional && VerticalGodslayerDashTimer < 25) + if (UsedDash.IsOmnidirectional && VerticalOmnidashTimer < 25) { - VerticalGodslayerDashTimer++; - if (VerticalGodslayerDashTimer >= 25) - { - Player.dashDelay = dashDelayToApply; - // Stop the player from going flying - Player.velocity *= 0.2f; - } - } - - if (UsedDash.IsOmnidirectional && VerticalSpeedBlasterDashTimer < 25) - { - VerticalSpeedBlasterDashTimer++; - if (VerticalSpeedBlasterDashTimer >= 25) + VerticalOmnidashTimer++; + if (VerticalOmnidashTimer >= 25) { Player.dashDelay = dashDelayToApply; // Stop the player from going flying diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 2292f77770..cea12b6330 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -442,6 +442,10 @@ namespace CalamityMod.CalPlayer { damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.HeavyBleeding" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); } + if (laceration) + { + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Laceration" + Main.rand.Next(1, 3 + 1)).ToNetworkText(Player.name)); + } if (elementalMix) { damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ElementalMix" + Main.rand.Next(1, 2 + 1)).Format(Player.name)); diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index a5ee7e9ba7..a2e2ac01bb 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -100,6 +100,7 @@ namespace CalamityMod.CalPlayer ApplyDoTDebuff(bBlood, 8, purity); ApplyDoTDebuff(brainRot, 8, purity); ApplyDoTDebuff(heavybleeding, 16, purity); + ApplyDoTDebuff(laceration, 24, purity); ApplyDoTDebuff(elementalMix, 50, purity); ApplyDoTDebuff(vaporfied, 8, purity); ApplyDoTDebuff(bFlames, abaddon ? 10 : 30, purity); diff --git a/CalPlayer/Dashes/SpeedBlasterDash.cs b/CalPlayer/Dashes/SpeedBlasterDash.cs index 9541964367..22772ab180 100644 --- a/CalPlayer/Dashes/SpeedBlasterDash.cs +++ b/CalPlayer/Dashes/SpeedBlasterDash.cs @@ -1,7 +1,11 @@ using CalamityMod.Enums; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; +using Terraria.ID; namespace CalamityMod.CalPlayer.Dashes { @@ -12,8 +16,6 @@ namespace CalamityMod.CalPlayer.Dashes public override bool IsOmnidirectional => true; - public bool dustOnce = true; - public override float CalculateDashSpeed(Player player) => 30f; public override void OnDashEffects(Player player) @@ -23,6 +25,15 @@ namespace CalamityMod.CalPlayer.Dashes public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) { + Dust trail = Dust.NewDustPerfect(player.Center + Main.rand.NextVector2Unit() * 12f, DustID.RainbowTorch, -player.velocity * 0.2f, 150, Color.Aqua, 1.2f); + trail.noGravity = true; + + Vector2 sparkVel = player.velocity.SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(-3f, -6f); + Color sparkColor = SpeedBlasterShot.GetColor(Main.rand.Next(5)); + float scale = Main.rand.NextFloat(1f, 1.6f); // Bloom effect is double the spark's size + Particle spark = new CritSpark(player.Center + Main.rand.NextVector2Unit() * 12f, sparkVel, Color.White, sparkColor, scale, 15, 0.5f, scale * 2f); + GeneralParticleHandler.SpawnParticle(spark); + // Fall way, way, faster than usual. player.maxFallSpeed = 50f; diff --git a/CalPlayer/Dashes/SuperradiantSawDash.cs b/CalPlayer/Dashes/SuperradiantSawDash.cs new file mode 100644 index 0000000000..a434d8d652 --- /dev/null +++ b/CalPlayer/Dashes/SuperradiantSawDash.cs @@ -0,0 +1,43 @@ +using CalamityMod.Enums; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; + +namespace CalamityMod.CalPlayer.Dashes +{ + public class SuperradiantSawDash : PlayerDashEffect + { + public static new string ID => "Superradiant Slaughterer"; + public override DashCollisionType CollisionType => DashCollisionType.NoCollision; + + public override bool IsOmnidirectional => true; + + public override float CalculateDashSpeed(Player player) => 36f; + + public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) + { + Dust trail = Dust.NewDustPerfect(player.Center + Main.rand.NextVector2Unit() * 12f, DustID.RainbowTorch, -player.velocity * 0.2f, 150, Color.Lime, 1.2f); + trail.noGravity = true; + + Vector2 sparkVel = player.velocity.SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(-3f, -6f); + Color sparkColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.25f); + float scale = Main.rand.NextFloat(1.2f, 2f); // Bloom effect is double the spark's size + Particle spark = new CritSpark(player.Center + Main.rand.NextVector2Unit() * 12f, sparkVel, Color.White, sparkColor, scale, 24, 0.5f, scale * 2f); + GeneralParticleHandler.SpawnParticle(spark); + + // Fall way, way, faster than usual. + player.maxFallSpeed = 50f; + + // Dash at a much, much faster speed than the default value. + dashSpeed = 24f; + runSpeedDecelerationFactor = 0.8f; + + // Cooldown for dash. + player.Calamity().SpeedBlasterDashStarted = false; + player.Calamity().sBlasterDashActivated = false; + } + } +} diff --git a/Cooldowns/SuperradiantSawBoost.cs b/Cooldowns/SuperradiantSawBoost.cs new file mode 100644 index 0000000000..17371e2aa1 --- /dev/null +++ b/Cooldowns/SuperradiantSawBoost.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.Localization; + +namespace CalamityMod.Cooldowns +{ + public class SuperradiantSawBoost : CooldownHandler + { + public static new string ID => "SuperradiantSawBoost"; + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/SuperradiantSawBoost"; + public override Color OutlineColor => new Color(207, 207, 207); + public override Color CooldownStartColor => new Color(122, 240, 58); + public override Color CooldownEndColor => new Color(32, 186, 171); + } +} diff --git a/Cooldowns/SuperradiantSawBoost.png b/Cooldowns/SuperradiantSawBoost.png new file mode 100644 index 0000000000..1cacbc5c4a Binary files /dev/null and b/Cooldowns/SuperradiantSawBoost.png differ diff --git a/Cooldowns/SuperradiantSawBoostOutline.png b/Cooldowns/SuperradiantSawBoostOutline.png new file mode 100644 index 0000000000..245f680cb5 Binary files /dev/null and b/Cooldowns/SuperradiantSawBoostOutline.png differ diff --git a/Cooldowns/SuperradiantSawBoostOverlay.png b/Cooldowns/SuperradiantSawBoostOverlay.png new file mode 100644 index 0000000000..da21d02b34 Binary files /dev/null and b/Cooldowns/SuperradiantSawBoostOverlay.png differ diff --git a/Items/Weapons/Ranged/ElementalBlaster.cs b/Items/Weapons/Ranged/ElementalBlaster.cs deleted file mode 100644 index 50c96f5885..0000000000 --- a/Items/Weapons/Ranged/ElementalBlaster.cs +++ /dev/null @@ -1,53 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Sounds; -using Microsoft.Xna.Framework; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Ranged -{ - public class ElementalBlaster : 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 = 104; - Item.height = 42; - Item.damage = 67; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 2; - Item.useAnimation = 6; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 1.75f; - Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; - Item.rare = ItemRarityID.Purple; - Item.UseSound = CommonCalamitySounds.PlasmaBoltSound; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 18f; - } - - public override Vector2? HoldoutOffset() - { - return new Vector2(-15, 0); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(ItemID.LunarBar, 5). - AddIngredient(5). - AddIngredient(5). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Ranged/ElementalBlaster.png b/Items/Weapons/Ranged/ElementalBlaster.png deleted file mode 100644 index 3ce7de1a2c..0000000000 Binary files a/Items/Weapons/Ranged/ElementalBlaster.png and /dev/null differ diff --git a/Items/Weapons/Ranged/SpeedBlaster.cs b/Items/Weapons/Ranged/SpeedBlaster.cs index 83a303c0bb..a146ae3b32 100644 --- a/Items/Weapons/Ranged/SpeedBlaster.cs +++ b/Items/Weapons/Ranged/SpeedBlaster.cs @@ -94,7 +94,8 @@ namespace CalamityMod.Items.Weapons.Ranged Color ColorUsed = SpeedBlasterShot.GetColor(ColorValue); for (int i = 0; i <= 8; i++) { - CritSpark spark = new CritSpark(player.Center, player.velocity.RotatedByRandom(MathHelper.ToRadians(13f)) * Main.rand.NextFloat(-2.1f, -4.5f), Color.White, ColorUsed, 2f, 45, 2f, 2.5f); + Vector2 sparkVel = player.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(MathHelper.ToRadians(45f)) * Main.rand.NextFloat(-28f, -36f); + CritSpark spark = new CritSpark(player.Center, sparkVel, Color.White, ColorUsed, 1.5f, 45, 0.5f, 2f); GeneralParticleHandler.SpawnParticle(spark); } } diff --git a/Items/Weapons/Ranged/SuperradiantSlaughterer.cs b/Items/Weapons/Ranged/SuperradiantSlaughterer.cs new file mode 100644 index 0000000000..45a7d7984d --- /dev/null +++ b/Items/Weapons/Ranged/SuperradiantSlaughterer.cs @@ -0,0 +1,132 @@ +using CalamityMod.Cooldowns; +using CalamityMod.Items.Materials; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Ranged; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + [LegacyName("ElementalBlaster")] + public class SuperradiantSlaughterer : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public const float ShootSpeed = 24f; + + public const int DashCooldown = 360; + + public override void ModifyTooltips(List tooltips) + { + if (tooltips == null) + return; + + Player player = Main.LocalPlayer; + if (player is null) + return; + + var mainTooltip = tooltips.FirstOrDefault(x => x.Text.Contains("[MAIN]") && x.Mod == "Terraria"); + if (mainTooltip != null) + { + mainTooltip.Text = Lang.SupportGlyphs(this.GetLocalizedValue("MainInfo")); + mainTooltip.OverrideColor = Color.Chartreuse; + } + var altTooltip = tooltips.FirstOrDefault(x => x.Text.Contains("[ALT]") && x.Mod == "Terraria"); + if (altTooltip != null) + { + altTooltip.Text = Lang.SupportGlyphs(this.GetLocalization("AltInfo").Format(DashCooldown / 60)); + altTooltip.OverrideColor = Color.SpringGreen; + } + } + + public override void SetStaticDefaults() + { + ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + } + public override void SetDefaults() + { + Item.width = 84; + Item.height = 46; + Item.damage = 127; + Item.DamageType = DamageClass.Ranged; + Item.useTime = 30; + Item.useAnimation = 30; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.channel = true; + Item.knockBack = 1.75f; + Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; + Item.rare = ItemRarityID.Purple; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = ShootSpeed; + Item.Calamity().canFirePointBlankShots = true; + } + + // Terraria seems to really dislike high crit values in SetDefaults + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 21; + public override bool AltFunctionUse(Player player) => true; + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2 && player.HasCooldown(SuperradiantSawBoost.ID)) + return false; + else + return player.ownedProjectileCounts[Item.shoot] <= 0; + } + + public override void HoldItem(Player player) + { + if (player.whoAmI != Main.myPlayer) + return; + + player.Calamity().mouseWorldListener = true; + player.Calamity().rightClickListener = true; + + // Right-click channeling + if (player.Calamity().mouseRight && CanUseItem(player) && !Main.mapFullscreen && !Main.blockMouse && !player.HasCooldown(SuperradiantSawBoost.ID)) + { + // Only one out at a time + if (Main.projectile.Any(n => n.active && n.type == Item.shoot && n.owner == player.whoAmI)) + return; + + int damage = (int)player.GetTotalDamage().ApplyTo(Item.damage); + float kb = player.GetTotalKnockback().ApplyTo(Item.knockBack); + + // 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction + Projectile.NewProjectile(Item.GetSource_FromThis(), player.Center, player.SafeDirectionTo(player.Calamity().mouseWorld), Item.shoot, damage * 2, kb, player.whoAmI, ai1: 2f); + } + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + // The holdout will initially double up when right clicking otherwise + if (player.altFunctionUse == 2) + return false; + + // The holdout deals 2x base damage. + Projectile.NewProjectile(source, position, velocity, Item.shoot, damage * 2, knockback, player.whoAmI); + return false; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(). + AddIngredient(ItemID.LunarBar, 5). + AddIngredient(5). + AddIngredient(ItemID.FragmentVortex, 5). + AddTile(TileID.MythrilAnvil). + Register(); + } + } +} diff --git a/Items/Weapons/Ranged/SuperradiantSlaughterer.png b/Items/Weapons/Ranged/SuperradiantSlaughterer.png new file mode 100644 index 0000000000..7dc18da67a Binary files /dev/null and b/Items/Weapons/Ranged/SuperradiantSlaughterer.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index 10d188ffc6..9cfdbd430a 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -168,6 +168,11 @@ GodSlayerInferno: { Description: Your flesh is burning off } +HeavyBleeding: { + DisplayName: Heavy Bleeding + Description: That's gonna need stitches +} + HolyFlames: { DisplayName: Holy Flames Description: Dissolving from holy light @@ -178,6 +183,11 @@ HolyInferno: { Description: You've gone too far from the Profaned Goddess! } +Laceration: { + DisplayName: Laceration + Description: You're a bloody mess +} + ManaBurn: { DisplayName: Mana Burn Description: The excess of mana sears your body and mind @@ -1505,8 +1515,3 @@ LiliesOfFinalityBuff: { DisplayName: Finality Description: Remember our promise } - -HeavyBleeding: { - Description: Mods.CalamityMod.Buffs.HeavyBleeding.Description - DisplayName: Heavy Bleeding -} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index db29caa352..f908e65ae5 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -426,15 +426,6 @@ Drataliornus: { ''' } -ElementalBlaster: { - DisplayName: Elemental Blaster - Tooltip: - ''' - Fires a storm of rainbow blasts - Does not consume ammo - ''' -} - ElementalEruption: { DisplayName: Elemental Eruption Tooltip: @@ -1153,9 +1144,10 @@ SpeedBlaster: { Tooltip: ''' Rapidly fires phosphorescent paintball shots - Press to eject a powerful glob which propels you while moving - This ability has a cooldown of {0} seconds - While under cooldown, you fire more rapidly with greater accuracy + Press to eject a powerful paint stream of a different color + Using this ability rapidly propels you in the direction you are moving + This ability has a {0} second cooldown + During this cooldown, you fire more rapidly with greater accuracy ''' } @@ -1222,6 +1214,31 @@ SulphuricAcidCannon: { Tooltip: Fires an acidic shot that sticks to enemies and dissolves them } +SuperradiantSlaughterer: { + DisplayName: Superradiant Slaughterer + Tooltip: + ''' + [MAIN] + [ALT] + [c/ad1717:'No one knows how it turns blood into rainbows...'] + ''' + MainInfo: + ''' + Hold to rev up an elemental buzzsaw that deals close-range damage + Release to fire the buzzsaw to pierce through and lacerate foes + Fired buzzsaws bounce off tiles and return to the player after winding down + When returning, the saws release extra homing bolts depending on the number of enemy and tile hits + Revving up the saws increases their damage and allows them to pierce more enemies + ''' + AltInfo: + ''' + Press to eject a lingering buzzsaw towards the cursor that fires homing bolts + Using this ability rapidly propels you in the direction you are moving + This ability has a {0} second cooldown + During this cooldown, buzzsaws home to the cursor and constantly release homing bolts while returning + ''' +} + SurgeDriver: { DisplayName: Surge Driver Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 4d89597d45..846e7cd6bc 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -220,6 +220,9 @@ StarmageddonStar2.DisplayName: Starmageddon Star StormSurgeTornado.DisplayName: Surge SulphuricBlast.DisplayName: Sulphuric Blast SuperballBulletProj.DisplayName: Superball Bullet +SuperradiantBolt.DisplayName: Superradiant Bolt +SuperradiantSawLingering.DisplayName: Ultraradiant Saw +SuperradiantSaw.DisplayName: Superradiant Saw TelluricGlareArrow.DisplayName: Radiant Arrow TheMaelstromExplosion.DisplayName: Reaper Explosion TheMaelstromShark.DisplayName: Reaper Shark diff --git a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson index 652459c985..485fdf71e0 100644 --- a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson +++ b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson @@ -70,6 +70,9 @@ HolyFlames1: "{0} fell prey to their sins." HolyFlames2: "{0} burst into sinless ash." HolyFlames3: "{0} was purified by the profaned flame." HolyInferno: "{0} was incinerated by the profaned backdraft." +Laceration1: "{0} was indecently smeared all over the walls." +Laceration2: "{0} was turned into a fine red mist." +Laceration3: "{0} was pulped, ribbons and rivulets of spent life spattering freely." ManaBurn: "{0}'s life was completely converted into mana." ManaConversionEnchant: "{0}'s life was fully tapped by dark magics." MiracleBlight1: "{0} was blown away by miraculous technological advancements." diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index 4037840c25..47a076ebb1 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -119,6 +119,7 @@ Cooldowns: { SpeedBlasterBoost: Speed Blaster Boost SpongeDurability: Sponge Barrier Durability SpongeRecharge: Sponge Barrier Recharge + SuperradiantSawBoost: Superradiant Saw Boost TarragonCloak: Tarragon Cloak Cooldown TarragonImmunity: Tarragon Immunity Cooldown UniverseSplitter: Universe Splitter Cooldown diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 96be2c2f7a..adb0f3c8c8 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -245,6 +245,7 @@ namespace CalamityMod.NPCs public int bBlood = 0; public int brainRot = 0; public int heavybleeding = 0; + public int laceration = 0; public int elementalMix = 0; public int marked = 0; public int absorberAffliction = 0; @@ -464,6 +465,7 @@ namespace CalamityMod.NPCs myClone.bBlood = bBlood; myClone.brainRot = brainRot; myClone.heavybleeding = heavybleeding; + myClone.laceration = laceration; myClone.elementalMix = elementalMix; myClone.marked = marked; myClone.absorberAffliction = absorberAffliction; @@ -1109,6 +1111,8 @@ namespace CalamityMod.NPCs ApplyDPSDebuff(40, 10, ref npc.lifeRegen, ref damage); if (heavybleeding > 0) ApplyDPSDebuff(80, 10, ref npc.lifeRegen, ref damage); + if (laceration > 0) + ApplyDPSDebuff(400, 100, ref npc.lifeRegen, ref damage); if (elementalMix > 0) ApplyDPSDebuff(400, 80, ref npc.lifeRegen, ref damage); if (miracleBlight > 0) @@ -5072,6 +5076,8 @@ namespace CalamityMod.NPCs brainRot--; if (heavybleeding > 0) heavybleeding--; + if (laceration > 0) + laceration--; if (elementalMix > 0) elementalMix--; if (vulnerabilityHex > 0) @@ -6361,6 +6367,9 @@ namespace CalamityMod.NPCs if (heavybleeding > 0) HeavyBleeding.DrawEffects(npc, ref drawColor); + if (laceration > 0) + Laceration.DrawEffects(npc, ref drawColor); + // These draw effects do not include Miracle Blight's shader if (miracleBlight > 0) MiracleBlight.DrawEffects(npc, ref drawColor); @@ -6556,6 +6565,7 @@ namespace CalamityMod.NPCs ("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno", NPC => NPC.Calamity().gsInferno > 0), ("CalamityMod/Buffs/DamageOverTime/HeavyBleeding", NPC => NPC.Calamity().heavybleeding > 0), ("CalamityMod/Buffs/DamageOverTime/HolyFlames", NPC => NPC.Calamity().hFlames > 0), + ("CalamityMod/Buffs/DamageOverTime/Laceration", NPC => NPC.Calamity().laceration > 0), ("CalamityMod/Buffs/DamageOverTime/MiracleBlight", NPC => NPC.Calamity().miracleBlight > 0), ("CalamityMod/Buffs/DamageOverTime/Nightwither", NPC => NPC.Calamity().nightwither > 0), ("CalamityMod/Buffs/DamageOverTime/Plague", NPC => NPC.Calamity().pFlames > 0), diff --git a/Projectiles/Ranged/BuzzkillSaw.cs b/Projectiles/Ranged/BuzzkillSaw.cs index d216260e25..7973eab163 100644 --- a/Projectiles/Ranged/BuzzkillSaw.cs +++ b/Projectiles/Ranged/BuzzkillSaw.cs @@ -44,6 +44,10 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + // dies from cringe (Deadshot Brooch moment) + if (Projectile.MaxUpdates > 1) + Projectile.MaxUpdates = 1; + Time++; Projectile.rotation += MathHelper.ToRadians(6f + 18f * SawLevel); diff --git a/Projectiles/Ranged/RainbowBlast.cs b/Projectiles/Ranged/RainbowBlast.cs deleted file mode 100644 index 545dfe829c..0000000000 --- a/Projectiles/Ranged/RainbowBlast.cs +++ /dev/null @@ -1,65 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class RainbowBlast : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - } - - public override void SetDefaults() - { - Projectile.width = 10; - Projectile.height = 10; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.extraUpdates = 1; - Projectile.DamageType = DamageClass.Ranged; - Projectile.timeLeft = 300; - } - - public override void AI() - { - //Rotation - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - - Lighting.AddLight(Projectile.Center, new Vector3(Main.DiscoR, Main.DiscoG, Main.DiscoB) * (1.5f / 255)); - - Projectile.localAI[0]++; - if (Projectile.localAI[0] > 5f) - { - Vector2 dspeed = -Projectile.velocity * 0.5f; - int rainbowDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, dspeed.X, dspeed.Y, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.1f); - Main.dust[rainbowDust].noGravity = true; - Main.dust[rainbowDust].velocity = dspeed; - } - - CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f); - } - - public override Color? GetAlpha(Color lightColor) - { - Color color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - return color; - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); - return false; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 60); - } - } -} diff --git a/Projectiles/Ranged/RainbowBlast.png b/Projectiles/Ranged/RainbowBlast.png deleted file mode 100644 index 80909384b5..0000000000 Binary files a/Projectiles/Ranged/RainbowBlast.png and /dev/null differ diff --git a/Projectiles/Ranged/SuperradiantBolt.cs b/Projectiles/Ranged/SuperradiantBolt.cs new file mode 100644 index 0000000000..2ba1733524 --- /dev/null +++ b/Projectiles/Ranged/SuperradiantBolt.cs @@ -0,0 +1,96 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SuperradiantBolt : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + + public ref float Time => ref Projectile.ai[0]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + ProjectileID.Sets.TrailCacheLength[Type] = 20; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 22; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 1; + Projectile.timeLeft = 120; + Projectile.tileCollide = false; + Projectile.scale = 0.85f; + } + + public override void AI() + { + Time++; + + // Solid homing + NPC potentialTarget = Projectile.Center.ClosestNPCAt(480f); + if (potentialTarget != null && Time >= 15f) + { + Vector2 idealVelocity = Projectile.SafeDirectionTo(potentialTarget.Center) * 24f; + Projectile.velocity = (Projectile.velocity * 29f + idealVelocity) / 30f; + Projectile.velocity = Projectile.velocity.MoveTowards(idealVelocity, 3f); + } + else if (Time >= 30f) + { + // Projectile decays a lot faster if there's no enemy in sight + Projectile.timeLeft -= 2; + } + + Projectile.rotation = Projectile.velocity.ToRotation(); + + // Emit light + DelegateMethods.v3_1 = Color.Lerp(Color.Lime, Color.White, 0.55f).ToVector3() * 0.35f; + Utils.PlotTileLine(Projectile.Center - Projectile.velocity * 0.5f, Projectile.Center + Projectile.velocity * 0.5f, 16f, DelegateMethods.CastLightOpen); + } + + public override bool? CanDamage() => Time >= 15f; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 45); + + internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 20f; + internal Color ColorFunction(float completionRatio) + { + float hue = 0.4f + 0.2f * completionRatio * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); + Color trailColor = Main.hslToRgb(hue, 1f, 0.8f); + return trailColor * Projectile.Opacity; + } + + public override bool PreDraw(ref Color lightColor) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 20); + Texture2D glow = TextureAssets.Projectile[Type].Value; + Main.EntitySpriteDraw(glow, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, glow.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + return false; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 2; i++) + { + Vector2 sparkVel = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(MathHelper.ToRadians(24f)) * Main.rand.NextFloat(6f, 10f); + Color color = Main.hslToRgb(Main.rand.NextFloat(0.3f, 0.5f), 1f, 0.8f); + SparkParticle spark = new(Projectile.Center, sparkVel, false, 30, 1.3f, color); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } +} diff --git a/Projectiles/Ranged/SuperradiantBolt.png b/Projectiles/Ranged/SuperradiantBolt.png new file mode 100644 index 0000000000..77ecaadda2 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantBolt.png differ diff --git a/Projectiles/Ranged/SuperradiantSaw.cs b/Projectiles/Ranged/SuperradiantSaw.cs new file mode 100644 index 0000000000..7c2e2c695a --- /dev/null +++ b/Projectiles/Ranged/SuperradiantSaw.cs @@ -0,0 +1,389 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SuperradiantSaw : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public static readonly SoundStyle TileCollideGFB = new("CalamityMod/Sounds/Custom/MetalPipeFalling"); + + public ref float SawLevel => ref Projectile.ai[0]; + public ref float Time => ref Projectile.ai[1]; + public ref float PierceBeforeReturn => ref Projectile.ai[2]; + + // Hitstop timer. + public int HitstopTimer = 0; + + // Controls if the saw is returning to the player. + public bool Returning = false; + public int ReturnTimer = 0; + public const int ReturnDelay = 90; + public const int MaxBoltPairs = 7; // No more than 7 pairs per saw + + // Whether the saw is empowered by right click. + public bool Empowered = false; + + public Particle SmallSlashSmear; + public Particle LargeSlashSmear; + public static Asset SawOutline; + public static Asset SmallSlash; + public static Asset LargeSlash; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 4; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 46; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.timeLeft = 600; + Projectile.penetrate = -1; // Saws only pierce a certain number of times before returning, and don't deal direct damage while returning + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + } + + public override void AI() + { + // dies from cringe (Deadshot Brooch moment) + if (Projectile.MaxUpdates > 1) + Projectile.MaxUpdates = 1; + + // Timer and rotation + Time++; + Projectile.rotation += MathHelper.ToRadians(6f + 18f * SawLevel); + + // Hitstop timer + if (HitstopTimer > 0) + { + HitstopTimer--; + if (HitstopTimer == 0) + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * SuperradiantSlaughterer.ShootSpeed; + } + + // Control the saw being empowered or not + Player Owner = Main.player[Projectile.owner]; + Empowered = Owner.HasCooldown(SuperradiantSawBoost.ID); + + // While empowered, the saws will slightly home in on the cursor + if (Empowered && !Returning && Time > 30) + { + float homingTurnSpeed = 0.2f; + Vector2 mouse = Owner.Calamity().mouseWorld; + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.SafeDirectionTo(mouse).ToRotation(), homingTurnSpeed).ToRotationVector2() * SuperradiantSlaughterer.ShootSpeed; + } + + // Saws automatically return 2 seconds after hitting an enemy + if (ReturnTimer > 0 && ReturnTimer < ReturnDelay) + { + ReturnTimer++; + if (ReturnTimer == ReturnDelay) + Returning = true; + } + + if (Returning) + { + Projectile.tileCollide = false; + if (ReturnTimer < ReturnDelay) + ReturnTimer = ReturnDelay; + + ReturnTimer++; + if (ReturnTimer < ReturnDelay + 30) + Projectile.velocity *= 0.95f; + else + { + // Spawns a burst of homing bolts when it starts returning, based on how many tiles and enemies it hit + if (ReturnTimer == ReturnDelay + 30) + { + int boltCount = Math.Min(Projectile.numHits, MaxBoltPairs) * 2; + for (int b = 0; b < boltCount; b++) + { + Vector2 randBoltVelocity = Main.rand.NextVector2Unit() * 9f; + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randBoltVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Main.myPlayer); + } + + // Extra burst of sparks for cool points + float sparkCount = 6f + 5f * SawLevel; + for (float i = 0f; i < sparkCount; i++) + { + Vector2 velocity = Main.rand.NextVector2Unit() * (12f + 10f * SawLevel); + float sparkScale = 1f + 0.25f * SawLevel; // Bloom effect is double the spark's size + Particle sparkle = new CritSpark(Projectile.Center, velocity, Color.White, Color.Lime, sparkScale, 30, 0.1f, sparkScale, Main.rand.NextFloat(0f, 0.01f)); + GeneralParticleHandler.SpawnParticle(sparkle); + } + } + + // Continuously spawn homing bolts as it returns while empowered + if (ReturnTimer % 9 == 0 && Empowered) + { + Vector2 randVelocity = -Projectile.velocity.RotatedByRandom(MathHelper.Pi / 3f) * 0.5f; + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Main.myPlayer); + } + + float returnSpeed = (SuperradiantSlaughterer.ShootSpeed * 0.6f) + (0.05f * (ReturnTimer - 120)); + Vector2 ownerDist = Owner.Center - Projectile.Center; + if (ownerDist.Length() > 3000f) + Projectile.Kill(); + + ownerDist.Normalize(); + ownerDist *= returnSpeed; + + // Home back in on the player; accelerates over time + if (Projectile.velocity.X < ownerDist.X) + Projectile.velocity.X = ownerDist.X; + else if (Projectile.velocity.X > ownerDist.X) + Projectile.velocity.X = ownerDist.X; + + if (Projectile.velocity.Y < ownerDist.Y) + Projectile.velocity.Y = ownerDist.Y; + else if (Projectile.velocity.Y > ownerDist.Y) + Projectile.velocity.Y = ownerDist.Y; + + // Delete the saw if it touches its owner + if (Main.myPlayer == Projectile.owner) + { + if (Projectile.Hitbox.Intersects(Owner.Hitbox)) + Projectile.Kill(); + } + } + } + else + { + // A bit of dust while travelling + if (Main.rand.NextBool()) + { + Color dustColor = Empowered ? Main.DiscoColor : new Color(Main.DiscoR, 255, 60); + Dust trail = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, Projectile.velocity.X * 0.05f, Projectile.velocity.Y * 0.05f, 150, dustColor, 1.2f); + trail.noGravity = true; + } + } + + // Rainbow smear particles which follow the path of the slashes + if (Empowered) + { + if (SawLevel >= 2f) + { + if (LargeSlashSmear == null) + { + LargeSlashSmear = new CircularSmearVFX(Projectile.Center, Color.Black, Time * -Projectile.rotation, 1.35f); + GeneralParticleHandler.SpawnParticle(LargeSlashSmear); + } + else + { + LargeSlashSmear.Rotation = -Projectile.rotation; + LargeSlashSmear.Time = 0; + LargeSlashSmear.Position = Projectile.Center; + LargeSlashSmear.Scale = 1.35f; + LargeSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.8f; + } + } + if (SawLevel >= 1f) + { + if (SmallSlashSmear == null) + { + SmallSlashSmear = new CircularSmearVFX(Projectile.Center, Color.Black, Projectile.rotation, 0.8f); + GeneralParticleHandler.SpawnParticle(SmallSlashSmear); + } + else + { + SmallSlashSmear.Rotation = Projectile.rotation; + SmallSlashSmear.Time = 0; + SmallSlashSmear.Position = Projectile.Center; + SmallSlashSmear.Scale = 0.8f; + SmallSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Cos(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.6f; + } + } + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + int sparkCount = 6 + 5 * (int)SawLevel; + for (int s = 0; s < sparkCount; s++) + { + Vector2 sparkVelocity = new Vector2(); + if (Projectile.velocity.X != oldVelocity.X && oldVelocity.X < 0) + sparkVelocity = Vector2.UnitX * 6.5f; + else if (Projectile.velocity.X != oldVelocity.X && oldVelocity.X >= 0) + sparkVelocity = Vector2.UnitX * -6.5f; + else if (Projectile.velocity.Y != oldVelocity.Y && oldVelocity.Y < 0) + sparkVelocity = Vector2.UnitY * 6.5f; + else if (Projectile.velocity.Y != oldVelocity.Y && oldVelocity.Y >= 0) + sparkVelocity = Vector2.UnitY * -6.5f; + + Vector2 sparkLocation = sparkVelocity.X > 0f ? Projectile.Left : (sparkVelocity.X < 0f ? Projectile.Right : (sparkVelocity.Y > 0f ? Projectile.Top : Projectile.Bottom)); + sparkVelocity = sparkVelocity.RotatedByRandom(MathHelper.PiOver2) * (Main.rand.NextFloat(0.8f, 1.2f) + (Main.rand.NextFloat(0.2f, 0.6f) * SawLevel)); + float scale = Main.rand.NextFloat(0.5f, 0.8f) + Main.rand.NextFloat(0.2f, 0.6f) * SawLevel; + Particle collisionSparks = new AltLineParticle(sparkLocation, sparkVelocity, false, 30, scale, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB)); + GeneralParticleHandler.SpawnParticle(collisionSparks); + } + + SoundEngine.PlaySound(Main.zenithWorld ? TileCollideGFB : SoundID.Item178 with { Pitch = 0.1f * Projectile.numHits }, Projectile.Center); // Placeholder sound + if (Projectile.velocity.X != oldVelocity.X) + Projectile.velocity.X = -oldVelocity.X; + if (Projectile.velocity.Y != oldVelocity.Y) + Projectile.velocity.Y = -oldVelocity.Y; + + if (PierceBeforeReturn > 0) + { + PierceBeforeReturn--; + Projectile.numHits++; + if (PierceBeforeReturn <= 0) + Returning = true; + } + + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 90); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice") with { Pitch = 0.1f * Projectile.numHits }, Projectile.Center); + + // SUPER COLORFUL PARTICLE EFFECTS YEAH + int onHitSparkAmount = 7 + 10 * (int)SawLevel; + for (int s = 0; s < onHitSparkAmount; s++) + { + Vector2 sparkVel = Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * (Main.rand.NextFloat(0.4f, 0.8f) + (Main.rand.NextFloat(0.4f, 0.6f) * SawLevel)); + float sparkSize = 0.4f + Main.rand.NextFloat(0.3f, 0.6f) * SawLevel; + Color sparkColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + + Particle sparked = new AltLineParticle(target.Center, sparkVel, false, 30, sparkSize, sparkColor); + GeneralParticleHandler.SpawnParticle(sparked); + } + for (int sq = 0; sq < 7; sq++) + { + Vector2 squareVel = Main.rand.NextVector2CircularEdge(1f, 1f) * (Main.rand.NextFloat(10f, 16f) + 5f * SawLevel); + float squareSize = 1.6f + Main.rand.NextFloat(1f, 1.6f) * SawLevel; + Color squareColor = Main.hslToRgb(Main.rand.NextFloat(), 0.6f, 0.8f); + + Particle squared = new SquareParticle(target.Center, squareVel, true, 30, squareSize, squareColor); + GeneralParticleHandler.SpawnParticle(squared); + } + + // Hitstop effect if the saw is not returning + if (!Returning && HitstopTimer == 0) + { + HitstopTimer = 5; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) / SuperradiantSlaughterer.ShootSpeed; + } + + if (Projectile.numHits < 1) + ReturnTimer = 1; + + if (PierceBeforeReturn > 0) + { + PierceBeforeReturn--; + if (PierceBeforeReturn <= 0) + Returning = true; + } + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + // The saw deals less damage while returning, to prevent its damage being too crazy + if (PierceBeforeReturn <= 0) + modifiers.SourceDamage *= 0.33f; + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/CeramicImpact", 2), Projectile.Center); + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + if (SawLevel >= 2f) + hitbox.Inflate(72, 72); + else if (SawLevel >= 1f) + hitbox.Inflate(32, 32); + } + + public override bool PreDraw(ref Color lightColor) + { + LargeSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawLargeSlash"); + Texture2D largeSlashTexture = LargeSlash.Value; + SmallSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawSmallSlash"); + Texture2D smallSlashTexture = SmallSlash.Value; + Color slashColor = new Color(200, 200, 200, 100); + + if (SawLevel >= 2f) + { + Main.EntitySpriteDraw(largeSlashTexture, Projectile.Center - Main.screenPosition, null, slashColor, -Projectile.rotation, largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time % 4 == 0) + { + Vector2 randomParticleOffset = new Vector2(Main.rand.NextFloat(-Projectile.width * 1.75f, Projectile.width * 1.75f), Main.rand.NextFloat(-Projectile.width * 1.75f, Projectile.width * 1.75f)); + float randomParticleScale = Main.rand.NextFloat(0.65f, 0.95f); + Color bloomColor = Color.Lerp(new Color(29, 120, 30), new Color(56, 255, 59), MathF.Abs(MathF.Sin(Time))); + Particle bloomCircle = new BloomParticle(Projectile.Center + randomParticleOffset, Projectile.velocity, Main.rand.NextBool() ? Color.White : bloomColor, randomParticleScale, randomParticleScale, 4, false); + GeneralParticleHandler.SpawnParticle(bloomCircle); + } + } + if (SawLevel >= 1f) + { + Main.EntitySpriteDraw(smallSlashTexture, Projectile.Center - Main.screenPosition, null, slashColor, Projectile.rotation, smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time % 4 == 0) + { + Vector2 randomParticleOffset = new Vector2(Main.rand.NextFloat(-Projectile.width, Projectile.width), Main.rand.NextFloat(-Projectile.width, Projectile.width)); + float randomParticleScale = Main.rand.NextFloat(0.35f, 0.65f); + Color bloomColor = Color.Lerp(new Color(29, 120, 30), new Color(56, 255, 59), MathF.Abs(MathF.Cos(Time))); + Particle bloomCircle = new BloomParticle(Projectile.Center + randomParticleOffset, Projectile.velocity, Main.rand.NextBool() ? Color.White : bloomColor, randomParticleScale, randomParticleScale, 4, false); + GeneralParticleHandler.SpawnParticle(bloomCircle); + } + } + + // Draw the saw itself at full brightness + Texture2D buzzsawTexture = TextureAssets.Projectile[Type].Value; + Main.EntitySpriteDraw(buzzsawTexture, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, buzzsawTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Empowered) // Rainbow outline while empowered + { + SawOutline ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawOutline"); + Texture2D outline = SawOutline.Value; + Main.EntitySpriteDraw(outline, Projectile.Center - Main.screenPosition, null, Main.DiscoColor, Projectile.rotation, outline.Size() * 0.5f, 1f, SpriteEffects.None); + } + + if (!CalamityConfig.Instance.Afterimages) + return false; + + // Special afterimage drawing to include the slashes + for (int i = 1; i < Projectile.oldPos.Length; i++) + { + float afterimageRot = Projectile.oldRot[i]; + + Vector2 drawPos = Projectile.oldPos[i] + buzzsawTexture.Size() * 0.5f - Main.screenPosition; + float intensity = MathHelper.Lerp(0.1f, 0.6f, 1f - i / (float)Projectile.oldPos.Length); + + Main.EntitySpriteDraw(buzzsawTexture, drawPos, null, lightColor * intensity, afterimageRot, buzzsawTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (SawLevel >= 2f) + Main.EntitySpriteDraw(largeSlashTexture, drawPos, null, slashColor * intensity, -afterimageRot, largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + if (SawLevel >= 1f) + Main.EntitySpriteDraw(smallSlashTexture, drawPos, null, slashColor * intensity, afterimageRot, smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + } + return false; + } + } +} diff --git a/Projectiles/Ranged/SuperradiantSaw.png b/Projectiles/Ranged/SuperradiantSaw.png new file mode 100644 index 0000000000..319c5357b2 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSaw.png differ diff --git a/Projectiles/Ranged/SuperradiantSawLargeSlash.png b/Projectiles/Ranged/SuperradiantSawLargeSlash.png new file mode 100644 index 0000000000..37ebc6a896 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSawLargeSlash.png differ diff --git a/Projectiles/Ranged/SuperradiantSawLingering.cs b/Projectiles/Ranged/SuperradiantSawLingering.cs new file mode 100644 index 0000000000..4e5619a351 --- /dev/null +++ b/Projectiles/Ranged/SuperradiantSawLingering.cs @@ -0,0 +1,198 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SuperradiantSawLingering : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/SuperradiantSaw"; + + public ref float Time => ref Projectile.ai[1]; + + public Particle SmallSlashSmear; + public Particle LargeSlashSmear; + public static Asset SawOutline; + public static Asset SmallSlash; + public static Asset LargeSlash; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 4; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + public override void SetDefaults() + { + Projectile.width = Projectile.height = 46; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.timeLeft = 270; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + } + + public override void AI() + { + // Timer and rotation + Time++; + Projectile.rotation += MathHelper.ToRadians(42f); + + // Make it lose velocity as it travels + Projectile.velocity *= 0.955f; + + // Continously spawn homing bolts and small saws + if (Time % 12 == 0 && Time > 30) + { + Vector2 randVelocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(7.5f, 9f); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Main.myPlayer); + } + + // Fade out at the end of its lifetime + if (Projectile.timeLeft <= 30) + { + Projectile.alpha += 8; + if (Projectile.alpha > 255) + Projectile.Kill(); + } + + // Rainbow smear particles which follow the path of the slashes + if (LargeSlashSmear == null) + { + LargeSlashSmear = new CircularSmearVFX(Projectile.Center, Color.Black, Time * -Projectile.rotation, 1.35f); + GeneralParticleHandler.SpawnParticle(LargeSlashSmear); + } + else + { + LargeSlashSmear.Rotation = -Projectile.rotation; + LargeSlashSmear.Time = 0; + LargeSlashSmear.Position = Projectile.Center; + LargeSlashSmear.Scale = 1.35f; + LargeSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.8f * Projectile.Opacity; + } + if (SmallSlashSmear == null) + { + SmallSlashSmear = new CircularSmearVFX(Projectile.Center, Color.Black, Projectile.rotation, 0.8f); + GeneralParticleHandler.SpawnParticle(SmallSlashSmear); + } + else + { + SmallSlashSmear.Rotation = Projectile.rotation; + SmallSlashSmear.Time = 0; + SmallSlashSmear.Position = Projectile.Center; + SmallSlashSmear.Scale = 0.8f; + SmallSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Cos(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.6f * Projectile.Opacity; + } + } + + public override bool? CanDamage() => Projectile.timeLeft > 30; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 90); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice"), Projectile.Center); + + // SUPER EPIC AND AWESOME PARTICLES + for (int s = 0; s < 12; s++) + { + Vector2 sparkVel = Main.rand.NextVector2CircularEdge(1f, 1f) * Main.rand.NextFloat(14f, 18f); + float sparkSize = Main.rand.NextFloat(1f, 1.4f); + Color sparkColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + + Particle sparked = new AltLineParticle(target.Center, sparkVel, false, 30, sparkSize, sparkColor); + GeneralParticleHandler.SpawnParticle(sparked); + } + for (int sq = 0; sq < 5; sq++) + { + Vector2 squareVel = Main.rand.NextVector2CircularEdge(1f, 1f) * Main.rand.NextFloat(10f, 16f); + float squareSize = Main.rand.NextFloat(3.2f, 4f); + Color squareColor = Main.hslToRgb(Main.rand.NextFloat(), 0.6f, 0.8f); + + Particle squared = new SquareParticle(target.Center, squareVel, true, 30, squareSize, squareColor); + GeneralParticleHandler.SpawnParticle(squared); + } + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/CeramicImpact", 2), Projectile.Center); + + for (int i = 0; i < 32; i++) + { + Vector2 velocity = ((MathHelper.TwoPi * i / 32f) - (MathHelper.Pi / 32f)).ToRotationVector2() * 32f; + Particle sparkle = new CritSpark(Projectile.Center, velocity, Color.White, Color.Lime, 1.5f, 30, 0.1f, 3f, Main.rand.NextFloat(0f, 0.01f)); + GeneralParticleHandler.SpawnParticle(sparkle); + } + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) => hitbox.Inflate(70, 70); + + public override bool PreDraw(ref Color lightColor) + { + LargeSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawLargeSlash"); + Texture2D largeSlashTexture = LargeSlash.Value; + SmallSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawSmallSlash"); + Texture2D smallSlashTexture = SmallSlash.Value; + Color slashColor = new Color(200, 200, 200, 100) * Projectile.Opacity; + + Main.EntitySpriteDraw(largeSlashTexture, Projectile.Center - Main.screenPosition, null, slashColor, -Projectile.rotation, largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time % 4 == 0) + { + Vector2 randomParticleOffset = new Vector2(Main.rand.NextFloat(-Projectile.width * 1.75f, Projectile.width * 1.75f), Main.rand.NextFloat(-Projectile.width * 1.75f, Projectile.width * 1.75f)); + float randomParticleScale = Main.rand.NextFloat(0.65f, 0.95f); + Color bloomColor = Color.Lerp(new Color(29, 120, 30), new Color(56, 255, 59), MathF.Abs(MathF.Sin(Time))); + Particle bloomCircle = new BloomParticle(Projectile.Center + randomParticleOffset, Projectile.velocity, Main.rand.NextBool() ? Color.White : bloomColor, randomParticleScale, randomParticleScale, 4, false); + GeneralParticleHandler.SpawnParticle(bloomCircle); + } + Main.EntitySpriteDraw(smallSlashTexture, Projectile.Center - Main.screenPosition, null, slashColor, Projectile.rotation, smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time % 4 == 0) + { + Vector2 randomParticleOffset = new Vector2(Main.rand.NextFloat(-Projectile.width, Projectile.width), Main.rand.NextFloat(-Projectile.width, Projectile.width)); + float randomParticleScale = Main.rand.NextFloat(0.35f, 0.65f); + Color bloomColor = Color.Lerp(new Color(29, 120, 30), new Color(56, 255, 59), MathF.Abs(MathF.Sin(Time))); + Particle bloomCircle = new BloomParticle(Projectile.Center + randomParticleOffset, Projectile.velocity, Main.rand.NextBool() ? Color.White : bloomColor, randomParticleScale, randomParticleScale, 4, false); + GeneralParticleHandler.SpawnParticle(bloomCircle); + } + + // Draw the saw itself at full brightness, glow and outline in rainbow + Texture2D buzzsawTexture = TextureAssets.Projectile[Type].Value; + Main.EntitySpriteDraw(buzzsawTexture, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, buzzsawTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + SawOutline ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawOutline"); + Texture2D outline = SawOutline.Value; + Main.EntitySpriteDraw(outline, Projectile.Center - Main.screenPosition, null, Main.DiscoColor, Projectile.rotation, outline.Size() * 0.5f, 1f, SpriteEffects.None); + + if (!CalamityConfig.Instance.Afterimages) + return false; + + // Special afterimage drawing to include the slashes + for (int i = 1; i < Projectile.oldPos.Length; i++) + { + float afterimageRot = Projectile.oldRot[i]; + Vector2 drawPos = Projectile.oldPos[i] + buzzsawTexture.Size() * 0.5f - Main.screenPosition; + float intensity = MathHelper.Lerp(0.1f, 0.6f, 1f - i / (float)Projectile.oldPos.Length); + + Main.EntitySpriteDraw(buzzsawTexture, drawPos, null, Color.White * intensity, afterimageRot, buzzsawTexture.Size() * 0.5f, 1f, SpriteEffects.None); + Main.EntitySpriteDraw(largeSlashTexture, drawPos, null, slashColor * intensity, -afterimageRot, largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + Main.EntitySpriteDraw(smallSlashTexture, drawPos, null, slashColor * intensity, afterimageRot, smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + } + return false; + } + } +} diff --git a/Projectiles/Ranged/SuperradiantSawOutline.png b/Projectiles/Ranged/SuperradiantSawOutline.png new file mode 100644 index 0000000000..87ec455489 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSawOutline.png differ diff --git a/Projectiles/Ranged/SuperradiantSawSmallSlash.png b/Projectiles/Ranged/SuperradiantSawSmallSlash.png new file mode 100644 index 0000000000..c8cf403c47 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSawSmallSlash.png differ diff --git a/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs new file mode 100644 index 0000000000..fd9d690fe4 --- /dev/null +++ b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs @@ -0,0 +1,352 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SuperradiantSlaughtererHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + public override float RecoilResolveSpeed => 0.05f; + public override float MaxOffsetLengthFromArm => 36f; + public override float BaseOffsetY => -5f; + public override float OffsetYUpwards => -5f; + public override float OffsetYDownwards => 5f; + public override Vector2 GunTipPosition => Projectile.Center + Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.width * 0.25f; + + public ref float Time => ref Projectile.ai[0]; + public const float ChargeupTime = 120f; + public SlotId ChargeIdle; + + // Controls the saw visually disappearing from the holdout when it fires. + public bool NoSawOnHoldout = false; + + public Particle SmallSlashSmear; + public Particle LargeSlashSmear; + public static Asset Holdout; + public static Asset HoldoutGlow; + public static Asset MiniSaw; + public static Asset SmallSlash; + public static Asset LargeSlash; + + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 5; + } + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override void KillHoldoutLogic() + { + if (HeldItem.type != Owner.ActiveItem().type) + { + Projectile.Kill(); + Projectile.netUpdate = true; + } + } + + public override void HoldoutAI() + { + Time++; + float SawPower = MathHelper.Clamp(Time / ChargeupTime, 0f, 1f); + + if (SoundEngine.TryGetActiveSound(ChargeIdle, out var Idle) && Idle.IsPlaying) + Idle.Position = GunTipPosition; + + // Handle the right-click dash (holds priority over left-click) + if (Owner.Calamity().mouseRight && !Owner.HasCooldown(SuperradiantSawBoost.ID)) + { + Owner.AddCooldown(SuperradiantSawBoost.ID, SuperradiantSlaughterer.DashCooldown); + Owner.Calamity().sBlasterDashActivated = true; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/MeatySlash"), GunTipPosition); + + // Throws a lingering saw at the cursor that deals 3x damage (since the holdout already deals 2x) + float clampedMouseDist = MathHelper.Clamp(Vector2.Distance(GunTipPosition, Owner.Calamity().mouseWorld), 0f, 960f); + float adjustedMouseDist = clampedMouseDist / 21f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * adjustedMouseDist, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), Projectile.knockBack, Projectile.owner); + + // Special case: right-clicking while not holding left-click + // This is to keep it friendly to use both fires at the same time, but end the animation early if not + if (Projectile.ai[1] >= 2f) + { + NoSawOnHoldout = true; + OffsetLengthFromArm -= 16f; + Projectile.timeLeft = Owner.ActiveItem().useAnimation; + KeepRefreshingLifetime = false; + Idle?.Stop(); + } + + // If moving, make particle effects when the dash activates + if (Owner.velocity != Vector2.Zero) + { + int particleAmt = 7; + for (int c = 0; c < particleAmt; c++) + { + Color sparkColor = Color.Lerp(new Color(122, 240, 58), new Color(32, 186, 171), c / (particleAmt - 1)); + Particle spark = new CritSpark(Owner.Center, Owner.velocity.RotatedByRandom(MathHelper.ToRadians(13f)) * Main.rand.NextFloat(-2.1f, -4.5f), Color.White, sparkColor, 2f, 45, 2.25f, 2f); + GeneralParticleHandler.SpawnParticle(spark); + } + for (int e = 0; e < particleAmt * 2; e++) + { + Color sparkColor2 = Color.Lerp(new Color(122, 240, 58), new Color(32, 186, 171), e / (particleAmt - 1)); + Particle spark2 = new NanoParticle(Owner.Center, Owner.velocity.RotatedByRandom(MathHelper.ToRadians(-MathHelper.PiOver4)) * Main.rand.NextFloat(2.5f, 4.5f), sparkColor2, 1f, 45, Main.rand.NextBool(3)); + GeneralParticleHandler.SpawnParticle(spark2); + } + } + } + else if (Owner.CantUseHoldout() && Projectile.ai[1] < 1f) + { + KeepRefreshingLifetime = false; + Idle?.Stop(); + + Projectile.ai[1] = 1f; + Projectile.timeLeft = Owner.ActiveItem().useAnimation; + SoundStyle ShootSound = new("CalamityMod/Sounds/Item/SawShot", 2) { PitchVariance = 0.1f, Volume = 0.4f + SawPower * 0.5f }; + SoundEngine.PlaySound(ShootSound, GunTipPosition); + + float sawDamageMult = MathHelper.Lerp(1f, 5f, SawPower) / 2f; // The damage must be divided by 2 to offset the holdout having 2x base damage. + int sawPierce = (int)MathHelper.Lerp(2f, 7f, SawPower); + int sawLevel = (SawPower >= 1f).ToInt() + (SawPower >= 0.25f).ToInt(); + + // ai[0] determines which slashes are drawn. ai[1] is the saw's timer variable. ai[2] stores the saw's pierce. + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * SuperradiantSlaughterer.ShootSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * sawDamageMult), Projectile.knockBack, Projectile.owner, sawLevel, 0f, sawPierce); + + NoSawOnHoldout = true; + OffsetLengthFromArm -= 4f + 12f * SawPower; + + int sparkPairCount = 3 + 2 * sawLevel; + for (int s = 0; s < sparkPairCount; s++) + { + float velocityMult = Main.rand.NextFloat(5f, 8f) + Main.rand.NextFloat(4f, 7f) * sawLevel; + float scale = Main.rand.NextFloat(0.6f, 0.8f) + Main.rand.NextFloat(0.3f, 0.5f) * sawLevel; + Color color = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + + Vector2 sparkVelocity = Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * velocityMult; + Particle weaponShootSparks = new AltLineParticle(GunTipPosition, sparkVelocity, false, 40, scale, color); + GeneralParticleHandler.SpawnParticle(weaponShootSparks); + + // re-randomize rotation for the alternate particle + sparkVelocity = Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * velocityMult; + Particle weaponShootSparks2 = new AltSparkParticle(GunTipPosition, sparkVelocity, false, 40, scale, color); + GeneralParticleHandler.SpawnParticle(weaponShootSparks2); + } + } + + if (NoSawOnHoldout) + { + Projectile.frame = 4; + return; + } + else + { + Projectile.frameCounter++; + if (Projectile.frameCounter >= 3) + { + Projectile.frameCounter = 0; + Projectile.frame++; + if (Projectile.frame > 3) + Projectile.frame = 0; + } + } + + // Smear particles which follow the path of the slashes + if (SawPower >= 1f) + { + if (LargeSlashSmear == null) + { + LargeSlashSmear = new CircularSmearVFX(GunTipPosition, Color.Black, Time * -MathHelper.ToRadians(42f), 1.35f); + GeneralParticleHandler.SpawnParticle(LargeSlashSmear); + } + else + { + LargeSlashSmear.Rotation = Time * -MathHelper.ToRadians(42f); + LargeSlashSmear.Time = 0; + LargeSlashSmear.Position = GunTipPosition; + LargeSlashSmear.Scale = 1.35f; + LargeSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.8f; + } + } + if (SawPower >= 0.25f) + { + if (SmallSlashSmear == null) + { + SmallSlashSmear = new CircularSmearVFX(GunTipPosition, Color.Black, Time * MathHelper.ToRadians(42f), 0.8f); + GeneralParticleHandler.SpawnParticle(SmallSlashSmear); + } + else + { + SmallSlashSmear.Rotation = Time * MathHelper.ToRadians(42f); + SmallSlashSmear.Time = 0; + SmallSlashSmear.Position = GunTipPosition; + SmallSlashSmear.Scale = 0.8f; + SmallSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Cos(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.6f; + } + } + + if (Time < ChargeupTime) + { + if (Time == 30f && !NoSawOnHoldout) + ChargeIdle = SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BuzzsawCharge") { Volume = 0.3f }, GunTipPosition); + } + else + { + if ((Time + 240) % 360 == 0) + ChargeIdle = SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BuzzsawIdle"), GunTipPosition); + + if (Time % 3 == 0) + { + Vector2 smokeVelocity = Vector2.UnitY * Main.rand.NextFloat(-7f, -12f); + smokeVelocity = smokeVelocity.RotatedByRandom(MathHelper.Pi / 8f); + Color smokeColor = Main.rand.NextBool() ? Main.DiscoColor : Color.Gray; + Particle fullChargeSmoke = new HeavySmokeParticle(GunTipPosition + Main.rand.NextVector2CircularEdge(3f, 3f), smokeVelocity, smokeColor, 30, 0.65f, 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), true); + GeneralParticleHandler.SpawnParticle(fullChargeSmoke); + } + } + } + + public override void OnSpawn(IEntitySource source) + { + base.OnSpawn(source); + ExtraBackArmRotation = MathHelper.ToRadians(15f); + } + + // Failsafe because apparently the sound doesn't stop sometimes + public override void OnKill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(ChargeIdle, out var Idle)) + Idle?.Stop(); + } + + // The holdout can deal damage; you're literally spinning up a buzzsaw at the end, after all. + public override bool? CanDamage() => !NoSawOnHoldout; + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + hitbox = new Rectangle((int)GunTipPosition.X - 23, (int)GunTipPosition.Y - 23, 46, 46); + + if (Time / ChargeupTime >= 1f) + hitbox.Inflate(72, 72); + else if (Time / ChargeupTime >= 0.25f) + hitbox.Inflate(32, 32); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(ModContent.BuffType(), 150); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice") { Volume = 0.7f }, GunTipPosition); + + // EPIC AND COOL RAINBOW PARTICLES WOOOO + int SawLevel = (Time / ChargeupTime >= 1f).ToInt() + (Time / ChargeupTime >= 0.25f).ToInt(); + int onHitSparkAmount = 4 + 4 * SawLevel; + for (int s = 0; s < onHitSparkAmount; s++) + { + Vector2 sparkVel = Main.rand.NextVector2CircularEdge(1f, 1f) * (Main.rand.NextFloat(6f, 10f) + 5f * SawLevel); + float sparkSize = 0.4f + Main.rand.NextFloat(0.3f, 0.6f) * SawLevel; + Color sparkColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + + Particle sparked = new AltLineParticle(target.Center, sparkVel, false, 20, sparkSize, sparkColor); + GeneralParticleHandler.SpawnParticle(sparked); + } + for (int sq = 0; sq < 5; sq++) + { + Vector2 squareVel = Main.rand.NextVector2CircularEdge(1f, 1f) * (Main.rand.NextFloat(6f, 10f) + 5f * SawLevel); + float squareSize = 1.6f + Main.rand.NextFloat(1f, 1.6f) * SawLevel; + Color squareColor = Main.hslToRgb(Main.rand.NextFloat(), 0.6f, 0.8f); + + Particle squared = new SquareParticle(target.Center, squareVel, true, 20, squareSize, squareColor); + GeneralParticleHandler.SpawnParticle(squared); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Holdout ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSlaughtererHoldout"); + Texture2D holdoutTexture = Holdout.Value; + LargeSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawLargeSlash"); + Texture2D largeSlashTexture = LargeSlash.Value; + SmallSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawSmallSlash"); + Texture2D smallSlashTexture = SmallSlash.Value; + Color slashColor = new Color(200, 200, 200, 100); + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = holdoutTexture.Frame(verticalFrames: Main.projFrames[Type], frameY: Projectile.frame); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = frame.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + if (!NoSawOnHoldout) + { + float shake = Utils.Remap(Time, 0f, ChargeupTime, 0f, 3f); + drawPosition += Main.rand.NextVector2Circular(shake, shake); + } + + // Mini saw drawn under the gun + MiniSaw ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSlaughtererHoldoutMiniSaw"); + Texture2D mini = MiniSaw.Value; + Vector2 verticalOffset = Vector2.UnitY.RotatedBy(Projectile.rotation); + if (Math.Cos(Projectile.rotation) < 0f) + verticalOffset *= -1f; + Vector2 miniSawPosition = drawPosition - Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.width * 0.125f + verticalOffset * 6f; + Main.EntitySpriteDraw(mini, miniSawPosition, null, Color.White, Time * MathHelper.ToRadians(24f), mini.Size() * 0.5f, Projectile.scale, flipSprite); + + Main.EntitySpriteDraw(holdoutTexture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale, flipSprite); + + // Glowmask + HoldoutGlow ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSlaughtererHoldoutGlow"); + Texture2D glow = HoldoutGlow.Value; + Main.EntitySpriteDraw(glow, drawPosition, frame, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); + + if (NoSawOnHoldout) + return false; + + if (Time > 30f) + { + if (Time / ChargeupTime >= 1f) + Main.EntitySpriteDraw(largeSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor, Time * -MathHelper.ToRadians(42f), largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time / ChargeupTime >= 0.25f) + Main.EntitySpriteDraw(smallSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor, Time * MathHelper.ToRadians(42f), smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (!CalamityConfig.Instance.Afterimages) + return false; + + // Special afterimage drawing for the slashes only + for (int i = 1; i < 3; i++) + { + float intensity = MathHelper.Lerp(0.05f, 0.25f, 1f - i / 3f); + + if (Time / ChargeupTime >= 1f) + Main.EntitySpriteDraw(largeSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor * intensity, (Time - i) * -MathHelper.ToRadians(42f), largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time / ChargeupTime >= 0.25f) + Main.EntitySpriteDraw(smallSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor * intensity, (Time - i) * MathHelper.ToRadians(42f), smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + } + } + + return false; + } + } +} diff --git a/Projectiles/Ranged/SuperradiantSlaughtererHoldout.png b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.png new file mode 100644 index 0000000000..e5445246aa Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.png differ diff --git a/Projectiles/Ranged/SuperradiantSlaughtererHoldoutGlow.png b/Projectiles/Ranged/SuperradiantSlaughtererHoldoutGlow.png new file mode 100644 index 0000000000..26c6b47fb4 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSlaughtererHoldoutGlow.png differ diff --git a/Projectiles/Ranged/SuperradiantSlaughtererHoldoutMiniSaw.png b/Projectiles/Ranged/SuperradiantSlaughtererHoldoutMiniSaw.png new file mode 100644 index 0000000000..5258525907 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSlaughtererHoldoutMiniSaw.png differ