From 97590f1d16ed3a4e55ac5bc4e9d9f7f6ad7956ea Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 28 Sep 2022 15:43:19 -0500 Subject: [PATCH] Reworked Virid Vanguard --- Buffs/Summon/ViridVanguardBuff.cs | 4 +- CalPlayer/CalamityPlayer.cs | 4 +- Items/CalamityGlobalItem.cs | 34 -- Items/Weapons/Summon/ViridVanguard.cs | 70 +-- Projectiles/Summon/ViridVanguardBlade.cs | 453 ++++++++++++++----- Projectiles/Summon/ViridVanguardBlade.png | Bin 2024 -> 1039 bytes Projectiles/Summon/ViridVanguardBladeAlt.png | Bin 2750 -> 0 bytes Utilities/DrawingUtils.cs | 15 +- 8 files changed, 365 insertions(+), 215 deletions(-) delete mode 100644 Projectiles/Summon/ViridVanguardBladeAlt.png diff --git a/Buffs/Summon/ViridVanguardBuff.cs b/Buffs/Summon/ViridVanguardBuff.cs index a304218317..4c092cb4a4 100644 --- a/Buffs/Summon/ViridVanguardBuff.cs +++ b/Buffs/Summon/ViridVanguardBuff.cs @@ -20,9 +20,9 @@ namespace CalamityMod.Buffs.Summon CalamityPlayer modPlayer = player.Calamity(); if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) { - modPlayer.viridVanguard = true; + modPlayer.ViridVanguard = true; } - if (!modPlayer.viridVanguard) + if (!modPlayer.ViridVanguard) { player.DelBuff(buffIndex); buffIndex--; diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index ac9c2aaee9..2855e7fded 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -961,7 +961,7 @@ namespace CalamityMod.CalPlayer public bool deathstareEyeball = false; public bool witherBlossom = false; public bool flowersOfMortality = false; - public bool viridVanguard = false; + public bool ViridVanguard = false; public bool sageSpirit = false; public bool fleshBall = false; public bool eyeOfNight = false; @@ -1997,7 +1997,7 @@ namespace CalamityMod.CalPlayer deathstareEyeball = false; witherBlossom = false; flowersOfMortality = false; - viridVanguard = false; + ViridVanguard = false; sageSpirit = false; fleshBall = false; eyeOfNight = false; diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index b27836fd9a..0f24e6513b 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -637,40 +637,6 @@ namespace CalamityMod.Items } return false; } - if (player.ActiveItem().type == ModContent.ItemType()) - { - int bladeCount = 0; - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].active && - Main.projectile[i].type == ModContent.ProjectileType() && - Main.projectile[i].owner == player.whoAmI && - Main.projectile[i].ModProjectile().FiringTime <= 0f) - { - bladeCount++; - } - } - if (bladeCount > 0) - { - int bladeIndex = 0; - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].ModProjectile is ViridVanguardBlade) - { - if (Main.projectile[i].ModProjectile().FiringTime > 0f) - continue; - } - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == player.whoAmI) - { - Main.projectile[i].ModProjectile().FiringTime = 240f; - Main.projectile[i].ModProjectile().RedirectAngle = MathHelper.Lerp(0f, MathHelper.TwoPi, bladeIndex / (float)bladeCount); - Main.projectile[i].netUpdate = true; - bladeIndex++; - } - } - } - return false; - } if (player.ActiveItem().type == ModContent.ItemType()) { bool hasBlades = false; diff --git a/Items/Weapons/Summon/ViridVanguard.cs b/Items/Weapons/Summon/ViridVanguard.cs index 95b8145f50..865fa2f254 100644 --- a/Items/Weapons/Summon/ViridVanguard.cs +++ b/Items/Weapons/Summon/ViridVanguard.cs @@ -10,19 +10,19 @@ namespace CalamityMod.Items.Weapons.Summon { public class ViridVanguard : ModItem { + public const float MaxTargetingDistance = 1550f; + public override void SetStaticDefaults() { DisplayName.SetDefault("Virid Vanguard"); - Tooltip.SetDefault("Summons 2 blades that rotate around you\n" + - "Each pair of blades takes up three minion slots\n" + - "Right clicking prompts all blades to fly upward and redirect towards the mouse"); + Tooltip.SetDefault("Update this"); Item.staff[Item.type] = true; SacrificeTotal = 1; } public override void SetDefaults() { - Item.damage = 280; + Item.damage = 210; Item.DamageType = DamageClass.Summon; Item.mana = 10; Item.width = 26; @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.noMelee = true; Item.knockBack = 5f; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; - Item.rare = 10; + Item.rare = ItemRarityID.Red; Item.UseSound = SoundID.Item71; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); @@ -41,71 +41,31 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float totalMinionSlots = 0f; - for (int i = 0; i < Main.maxProjectiles; i++) + if (player.altFunctionUse != 2) { - if (Main.projectile[i].active && Main.projectile[i].minion && Main.projectile[i].owner == player.whoAmI) + int p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); + if (Main.projectile.IndexInRange(p)) { - totalMinionSlots += Main.projectile[i].minionSlots; - } - } - if (player.altFunctionUse != 2 && totalMinionSlots + 1.5f < player.maxMinions) - { - position = Main.MouseWorld; - int swordCount = 0; - for (int i = 0; i < Main.projectile.Length; i++) - { - if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI) - { - if ((Main.projectile[i].ModProjectile as ViridVanguardBlade).FiringTime > 0f) - continue; - swordCount++; - for (int j = 0; j < 22; j++) - { - Dust dust = Dust.NewDustDirect(Main.projectile[i].position, Main.projectile[i].width, Main.projectile[i].height, 2); - dust.velocity = Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f) * Main.rand.NextBool(2).ToDirectionInt(); - dust.noGravity = true; - } - } + Main.projectile[p].originalDamage = Item.damage; + Main.projectile[p].ModProjectile().BladeIndex = player.ownedProjectileCounts[type]; } - Projectile newBlade = Projectile.NewProjectileDirect(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - (newBlade.ModProjectile as ViridVanguardBlade).AltTexture = swordCount % 2 == 1; - newBlade.originalDamage = Item.damage; - newBlade.netUpdate = true; - swordCount++; - - newBlade = Projectile.NewProjectileDirect(source, position, Vector2.Zero, type, damage, knockback, player.whoAmI); - (newBlade.ModProjectile as ViridVanguardBlade).AltTexture = swordCount % 2 == 1; - newBlade.originalDamage = Item.damage; - newBlade.netUpdate = true; - swordCount++; - - float angleVariance = MathHelper.TwoPi / swordCount; - float angle = 0f; for (int i = 0; i < Main.maxProjectiles; i++) { - if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI) + if (Main.projectile[i].type == type && Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) { - if ((Main.projectile[i].ModProjectile as ViridVanguardBlade).FiringTime > 0f) - continue; - Main.projectile[i].ai[0] = angle; - Main.projectile[i].localAI[1] = 80f; - angle += angleVariance; - for (int j = 0; j < 22; j++) - { - Dust dust = Dust.NewDustDirect(Main.projectile[i].position, Main.projectile[i].width, Main.projectile[i].height, 6); - dust.velocity = Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f) * Main.rand.NextBool(2).ToDirectionInt(); - dust.noGravity = true; - } + Main.projectile[i].ModProjectile().AITimer = 0f; + Main.projectile[i].netUpdate = true; } } } + return false; } public override void AddRecipes() { CreateRecipe(). + AddIngredient(ItemID.EmpressBlade). AddIngredient(). AddIngredient(8). AddTile(TileID.LunarCraftingStation). diff --git a/Projectiles/Summon/ViridVanguardBlade.cs b/Projectiles/Summon/ViridVanguardBlade.cs index 94d0ed9e92..19981b5be5 100644 --- a/Projectiles/Summon/ViridVanguardBlade.cs +++ b/Projectiles/Summon/ViridVanguardBlade.cs @@ -1,10 +1,14 @@ using System; using System.IO; using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; +using Terraria.Graphics; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -12,174 +16,385 @@ namespace CalamityMod.Projectiles.Summon { public class ViridVanguardBlade : ModProjectile { - public bool AltTexture = false; - - public int RemainingSlices = 0; - public int PostSliceDeathTimer; - public float RedirectAngle; - public float FiringTime = 0f; - public Vector2 IdealPosition; - public float Angle + public enum ViridVanguardAIState { - get => Projectile.ai[0]; - set => Projectile.ai[0] = value; + CircleOwner, + HorizontalSlashes, + VerticalPierceTeleport, + RegularPierceSlashes, } + + public int BladeIndex; + + public VertexStrip TrailDrawer; + + public Vector2 ChargeStartingPosition; + + public float BladeHoverOffsetAngle + { + get + { + float projectileCounts = Owner.ownedProjectileCounts[Type]; + if (projectileCounts <= 1f) + projectileCounts = 1f; + + return MathHelper.TwoPi * BladeIndex / projectileCounts + AITimer / 27f; + } + } + + public ViridVanguardAIState CurrentState + { + get => (ViridVanguardAIState)Projectile.ai[0]; + set => Projectile.ai[0] = (int)value; + } + + public Player Owner => Main.player[Projectile.owner]; + + public ref float AITimer => ref Projectile.ai[1]; + + public ref float BladeGleamInterpolant => ref Projectile.localAI[0]; + public override void SetStaticDefaults() { DisplayName.SetDefault("Vanguard Blade"); - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 7; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 45; } public override void SetDefaults() { - Projectile.width = 60; - Projectile.height = 156; + Projectile.width = 84; + Projectile.height = 84; Projectile.netImportant = true; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.minionSlots = 1.5f; - Projectile.timeLeft = 18000; + Projectile.timeLeft = 90000; Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 14; Projectile.tileCollide = false; - Projectile.timeLeft *= 5; Projectile.minion = true; Projectile.DamageType = DamageClass.Summon; } + public override void SendExtraAI(BinaryWriter writer) { - writer.Write(RedirectAngle); - writer.Write(FiringTime); - writer.Write(AltTexture); + writer.Write(BladeIndex); + writer.WriteVector2(ChargeStartingPosition); } + public override void ReceiveExtraAI(BinaryReader reader) { - RedirectAngle = reader.ReadSingle(); - FiringTime = reader.ReadSingle(); - AltTexture = reader.ReadBoolean(); + BladeIndex = reader.ReadInt32(); + ChargeStartingPosition = reader.ReadVector2(); } + public override void AI() { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - Projectile.spriteDirection = AltTexture.ToDirectionInt(); - bool isProperProjectile = Projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (isProperProjectile) + // Decide whether the minion should still exist. + HandleMinionBools(); + + // Reset extra updates. + Projectile.MaxUpdates = 1; + + // Have the gleam interpolant dissipate. + BladeGleamInterpolant = MathHelper.Lerp(BladeGleamInterpolant, 0f, 0.1f); + if (BladeGleamInterpolant <= 0.02f) + BladeGleamInterpolant = 0f; + + NPC potentialTarget = Projectile.Center.MinionHoming(ViridVanguard.MaxTargetingDistance, Owner); + switch (CurrentState) { - if (player.dead) - { - modPlayer.viridVanguard = false; - } - if (modPlayer.viridVanguard) - { - Projectile.timeLeft = 2; - } + case ViridVanguardAIState.CircleOwner: + DoBehavior_CircleOwner(potentialTarget); + break; + case ViridVanguardAIState.HorizontalSlashes: + DoBehavior_HorizontalSlashes(potentialTarget); + break; + case ViridVanguardAIState.VerticalPierceTeleport: + DoBehavior_VerticalPierceTeleport(potentialTarget); + break; + case ViridVanguardAIState.RegularPierceSlashes: + DoBehavior_RegularPierceSlashes(potentialTarget); + break; } - if (FiringTime <= 0f) + AITimer++; + } + + public void DoBehavior_CircleOwner(NPC potentialTarget) + { + // Begin attacking if an enemy is nearby. + if (potentialTarget is not null) { - Projectile.ai[1]++; - float outwardPosition = 320f; - outwardPosition += (float)Math.Sin(Angle) * 200f; - Projectile.Center = player.Center + Angle.ToRotationVector2().RotatedBy((float)Math.Cos(Angle) * MathHelper.PiOver4 + AltTexture.ToInt() * MathHelper.Pi) * outwardPosition; - Projectile.rotation = player.AngleTo(Projectile.Center) + MathHelper.PiOver4; - Angle += MathHelper.ToRadians(4f); + CurrentState = ViridVanguardAIState.HorizontalSlashes; + AITimer = 0f; + Projectile.netUpdate = true; + return; } + + Vector2 hoverDestination = Owner.Center + BladeHoverOffsetAngle.ToRotationVector2() * 200f; + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.04f).MoveTowards(hoverDestination, 16f); + Projectile.velocity *= 0.8f; + + // Teleport to the owner if sufficiently far away. + if (!Projectile.WithinRange(Owner.Center, 2500f)) + { + Projectile.Center = hoverDestination; + Projectile.netUpdate = true; + } + + // Aim away from the target. + Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; + } + + public void DoBehavior_HorizontalSlashes(NPC target) + { + int hoverTime = 22; + int chargeTime = 14; + int chargeCount = 7; + float chargeSpeed = 44f; + + // Exit the attack state if the blade no longer has a valid target. + if (target is null) + { + ReturnToIdleState(); + return; + } + + // Use extra updates to make the swords move faster than normal. + Projectile.MaxUpdates = 2; + + // Use a gleam effect right before and during charges. + float wrappedAttackTimer = AITimer % (hoverTime + chargeTime); + float fadeIn = Utils.GetLerpValue(hoverTime - 6f, hoverTime, wrappedAttackTimer, true); + float fadeOut = Utils.GetLerpValue(chargeTime, chargeTime - 6f, wrappedAttackTimer - hoverTime, true); + BladeGleamInterpolant = fadeIn * fadeOut; + + // Hover to the side of the target. + if (wrappedAttackTimer < hoverTime) + { + Vector2 hoverDestination = target.Center + Vector2.UnitX * (target.Center.X < Projectile.Center.X).ToDirectionInt() * 250f; + hoverDestination.Y += (float)Math.Cos(Projectile.identity * 1.7f) * 67f; + + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.08f).MoveTowards(hoverDestination, 16f); + Projectile.velocity *= 0.5f; + + // Update rotation, to look upward. + Projectile.rotation = Projectile.rotation.AngleLerp(0f, 0.08f); + } + + // Otherwise, if not hovering, update rotation to swing forward somewhat. else + Projectile.rotation += Math.Sign(Projectile.velocity.X) * MathHelper.Pi / chargeTime * 0.36f; + + // Charge VERY quickly at the target once ready. + if (wrappedAttackTimer == hoverTime) { - Projectile.spriteDirection = 1; - if (FiringTime >= 239f) - { - RemainingSlices = Projectile.penetrate = 3; - IdealPosition = player.Center - Vector2.UnitY.RotatedBy(RedirectAngle) * 550f; - } - else if (FiringTime > 120f) - { - Projectile.Center = Vector2.Lerp(Projectile.Center, IdealPosition, 1f / 40f); - Projectile.rotation = Projectile.rotation.AngleLerp(RedirectAngle + MathHelper.ToRadians(82f), 1f / 60f); - } - else if (FiringTime > 80f) - { - Projectile.Center = IdealPosition; - Projectile.rotation = Projectile.rotation.AngleLerp(Projectile.AngleTo(Main.MouseWorld) + MathHelper.ToRadians(82f), 1f / 20f); - } - else if (FiringTime == 80f) - { - PostSliceDeathTimer = 80; - Projectile.velocity = Projectile.SafeDirectionTo(Main.MouseWorld) * 30f; - } - else if (FiringTime == 1f) - { - if (RemainingSlices <= 0) - { - Projectile.Kill(); - } - else if (RemainingSlices <= 2) - { - Projectile.velocity *= -1; - FiringTime = 20f; - } - } - FiringTime--; + SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Pitch = 1.6f, Volume = 0.27f }, Projectile.Center); + Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; + Projectile.velocity = Vector2.UnitX * (target.Center.X > Projectile.Center.X).ToDirectionInt() * chargeSpeed; + Projectile.netUpdate = true; } - if (RemainingSlices > 0) - PostSliceDeathTimer--; - if (PostSliceDeathTimer == 1) - Projectile.Kill(); + // Switch to the next attack state once enough charges have happened. + if (AITimer >= (hoverTime + chargeTime) * chargeCount) + { + AITimer = 0f; + CurrentState = ViridVanguardAIState.VerticalPierceTeleport; + Projectile.netUpdate = true; + } + } - if (Projectile.localAI[1] > 0) - { - Projectile.alpha = (int)MathHelper.Lerp(255, 0, 1f - Projectile.localAI[1] / 80f); - Projectile.localAI[1]--; - } - } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + public void DoBehavior_VerticalPierceTeleport(NPC target) { - if (RemainingSlices > 0 && FiringTime <= 80f) + int hoverTime = 26; + int chargeTime = 32; + int chargeCount = 7; + float chargeSpeed = 45f; + + // Exit the attack state if the blade no longer has a valid target. + if (target is null) { - FiringTime = 10f; - RemainingSlices--; + ReturnToIdleState(); + return; + } + + // Use extra updates to make the swords move faster than normal. + Projectile.MaxUpdates = 2; + + // Use a gleam effect right before and during charges. + int localAITimer = (int)AITimer + Projectile.identity / 2; + float wrappedAttackTimer = localAITimer % (hoverTime + chargeTime); + float fadeIn = Utils.GetLerpValue(hoverTime - 6f, hoverTime, wrappedAttackTimer, true); + float fadeOut = Utils.GetLerpValue(chargeTime, chargeTime - 6f, wrappedAttackTimer - hoverTime, true); + BladeGleamInterpolant = fadeIn * fadeOut; + + // Hover above the target. + if (wrappedAttackTimer < hoverTime) + { + Vector2 hoverDestination = target.Center - Vector2.UnitY * 500f; + hoverDestination.X += (float)Math.Cos(Projectile.identity * 1.7f) * 50f; + + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.08f).MoveTowards(hoverDestination, 16f); + Projectile.velocity *= 0.5f; + + // Update rotation, to look at the target. + Projectile.rotation = Projectile.rotation.AngleLerp(Projectile.AngleTo(target.Center) + MathHelper.PiOver2, 0.24f); + } + + // Pierce the target once ready. + if (wrappedAttackTimer == hoverTime) + { + SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Pitch = 1.6f, Volume = 0.27f }, Projectile.Center); + Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; + Projectile.velocity = Vector2.UnitY * chargeSpeed; + Projectile.netUpdate = true; + } + + // Teleport above the target once sufficiently far below them. + if (wrappedAttackTimer >= hoverTime + 5f && Projectile.Center.Y > target.Center.Y + 850f) + { + Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; + Projectile.Center = target.Center - Vector2.UnitY * 600f; + Projectile.netUpdate = true; + } + + // Switch to the next attack state once enough charges have happened. + if (AITimer >= (hoverTime + chargeTime) * chargeCount) + { + AITimer = 0f; + CurrentState = ViridVanguardAIState.RegularPierceSlashes; + Projectile.netUpdate = true; } } - public override void Kill(int timeLeft) + + public void DoBehavior_RegularPierceSlashes(NPC target) { - for (int j = 0; j < 40; j++) + int attackCycleTime = 44; + int chargeCount = 8; + float upwardRiseTimeRatio = 0.4f; + float pierceTimeRatio = 0.14f; + + // Exit the attack state if the blade no longer has a valid target. + if (target is null) { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 66); - dust.velocity = Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f) * Main.rand.NextBool(2).ToDirectionInt(); - dust.noGravity = true; + ReturnToIdleState(); + ChargeStartingPosition = Vector2.Zero; + return; + } + + // Initialize the starting position on the first frame. + int localAITimer = (int)AITimer + Projectile.identity; + if (localAITimer % attackCycleTime == 1f) + { + ChargeStartingPosition = Projectile.Center + Main.rand.NextVector2Circular(80f, 80f); + Projectile.netUpdate = true; + } + + float attackCompletion = localAITimer / (float)attackCycleTime % 1f; + + // Reset the trail point array if aiming at the target. + if (attackCompletion < upwardRiseTimeRatio) + Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; + + // Use extra updates to make the swords move faster than normal. + Projectile.MaxUpdates = 2; + + // This represents the entire attack cycle in a single interpolant via a bunch of GetLerpValues and vector math. The patterns is as follows: + // 1. Hover very quickly to the starting position. + // 2. Rise upward somewhat. + // 3. Lerp towards the target rapidly. + // 4. Lerp through the target rapidly. + // 5. Repeat. + float offsetDistanceFactor = MathHelper.Lerp(1.61f, 3f, Projectile.identity / 7f % 1f); + Vector2 startingPosition = ChargeStartingPosition + Vector2.UnitY * Utils.GetLerpValue(0f, upwardRiseTimeRatio, attackCompletion, true) * -200f; + Vector2 targetOffset = target.Center - startingPosition; + Vector2 endingPosition = target.Center + targetOffset.SafeNormalize(Vector2.Zero) * MathHelper.Clamp(targetOffset.Length(), 60f, 240f) * offsetDistanceFactor; + float pierceCompletion = Utils.GetLerpValue(upwardRiseTimeRatio, upwardRiseTimeRatio + pierceTimeRatio, attackCompletion, true); + float throughTargetCompletion = Utils.GetLerpValue(upwardRiseTimeRatio + pierceTimeRatio, 1f, attackCompletion, true); + + // Update rotation and interpolate through the necessary positions. + Projectile.rotation = Projectile.rotation.AngleTowards(targetOffset.ToRotation() + MathHelper.PiOver2, MathHelper.Pi / 5f); + Projectile.Center = Vector2.Lerp(Projectile.Center, Vector2.Lerp(startingPosition, target.Center, pierceCompletion), pierceCompletion * 0.5f); + if (throughTargetCompletion > 0f) + Projectile.Center = Vector2.Lerp(target.Center, endingPosition, throughTargetCompletion); + Projectile.velocity = Vector2.Zero; + + // Play a slice sound once ready to charge. + if (localAITimer % attackCycleTime == (int)(attackCycleTime * upwardRiseTimeRatio)) + SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Pitch = 1.6f, Volume = 0.27f }, Projectile.Center); + + // Switch to the next attack state once enough charges have happened. + if (localAITimer >= attackCycleTime * chargeCount) + { + AITimer = 0f; + CurrentState = ViridVanguardAIState.HorizontalSlashes; + Projectile.netUpdate = true; } } + + public void ReturnToIdleState() + { + AITimer = 0f; + CurrentState = ViridVanguardAIState.CircleOwner; + Projectile.netUpdate = true; + } + + public void HandleMinionBools() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Projectile.type == ModContent.ProjectileType()) + { + if (Owner.dead) + Owner.Calamity().ViridVanguard = false; + + if (Owner.Calamity().ViridVanguard) + Projectile.timeLeft = 2; + } + } + + public Color TrailColorFunction(float completionRatio) + { + float opacity = (float)Math.Pow(Utils.GetLerpValue(1f, 0.45f, completionRatio, true), 4D) * Projectile.Opacity; + return Color.Lerp(new(115, 196, 127), Color.Yellow, MathHelper.Clamp(completionRatio * 1.4f, 0f, 1f)) * opacity; + } + + public float TrailWidthFunction(float completionRatio) => Projectile.height * (1f - completionRatio) * 0.8f; + public override bool PreDraw(ref Color lightColor) { - Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Summon/ViridVanguardBlade" + (AltTexture ? "" : "Alt")).Value; + Texture2D texture = ModContent.Request(Texture).Value; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Rectangle rectangle = new Rectangle(0, 0, texture.Width, texture.Height); + TrailDrawer ??= new(); + GameShaders.Misc["EmpressBlade"].UseImage0("Images/Extra_201"); + GameShaders.Misc["EmpressBlade"].UseImage1("Images/Extra_193"); + GameShaders.Misc["EmpressBlade"].UseShaderSpecificData(new Vector4(1f, 0f, 0f, 0.6f)); + GameShaders.Misc["EmpressBlade"].Apply(null); + TrailDrawer.PrepareStrip(Projectile.oldPos, Projectile.oldRot, TrailColorFunction, TrailWidthFunction, Projectile.Size * 0.5f - Main.screenPosition, Projectile.oldPos.Length, true); + TrailDrawer.DrawTrail(); + Main.pixelShader.CurrentTechnique.Passes[0].Apply(); - SpriteEffects spriteEffects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + // Draw the blade. + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation + 0.2f, origin, Projectile.scale, direction, 0); - if (CalamityConfig.Instance.Afterimages && FiringTime > 0f && FiringTime < 80f) - { - for (int i = 0; i < Projectile.oldPos.Length; i++) - { - Vector2 drawPos = Projectile.oldPos[i] + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color color = Color.Lerp(Color.White, Color.DarkOliveGreen, i / (float)Projectile.oldPos.Length) * - ((Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length); - float scale = MathHelper.Lerp(Projectile.scale * 1f, Projectile.scale * 0.5f, i / (float)Projectile.oldPos.Length); - Main.EntitySpriteDraw(texture, drawPos, new Rectangle?(rectangle), color, - Projectile.rotation, - rectangle.Size() / 2f, scale, SpriteEffects.None, 0); - } - } - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Rectangle?(rectangle), Color.White, - Projectile.rotation, - rectangle.Size() / 2f, 1f, spriteEffects, 0); + // Draw the gleam. + Texture2D shineTex = ModContent.Request("CalamityMod/Particles/HalfStar").Value; + Vector2 shineScale = new Vector2(1.67f, 3f) * Projectile.scale; + shineScale *= MathHelper.Lerp(0.9f, 1.1f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 7.4f + Projectile.identity) * 0.5f + 0.5f); + + Vector2 lensFlareWorldPosition = Projectile.Center + (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * Projectile.width * Projectile.scale * 0.88f; + Color lensFlareColor = Color.Lerp(Color.LimeGreen, Color.Yellow, 0.23f) with { A = 0 } * BladeGleamInterpolant; + Main.EntitySpriteDraw(shineTex, lensFlareWorldPosition - Main.screenPosition, null, lensFlareColor, 0f, shineTex.Size() * 0.5f, shineScale * 0.6f, 0, 0); + Main.EntitySpriteDraw(shineTex, lensFlareWorldPosition - Main.screenPosition, null, lensFlareColor, MathHelper.PiOver2, shineTex.Size() * 0.5f, shineScale, 0, 0); + + // Reset textures for shaders. + GameShaders.Misc["EmpressBlade"].UseImage0("Images/Extra_209"); + GameShaders.Misc["EmpressBlade"].UseImage1("Images/Extra_210"); return false; } } diff --git a/Projectiles/Summon/ViridVanguardBlade.png b/Projectiles/Summon/ViridVanguardBlade.png index dadc21641b966b5ebc78b51fe458c821558cfeb0..e2cbaf204065d350318d6fed2d1b8a0483ac6865 100644 GIT binary patch delta 1024 zcmV+b1poW!503~TiBL{Q4GJ0x0000DNk~Le0000q0001{2m=5B0HO$7k&z)Ee*iF0 zOjJcS5eC+^Q&J@~u52#<-L8N}GGLrHo6M{>J3T{VQ!XJI0000*J||gjCLkgt0000! z>_OcC000n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vJ}6~7tBT+Rl+y2E{qK`@$2JvS)q73Vfz z&1>@04?aEgaKp343r0LUgI_%@V7g@1@K#~zp{WNMdBZIXCItPT@Fz3oP|HL{hKGEs ztt{9wb68*R6Z11*U7V^V=ewry_6-hx$D@}OgIp|Q3>F*{nPa^zd98LgbAr=trv&Lk z@%z*!`8`(2c*;GyVdrX~=R|TO4m5sUHNjDG&JkapQyVl{0`@8edd4i&y1c9JvB8B+ zbN6(AIsMQ+@nOWL6A8U)(+(Lb2=FpjaBSgctgngL@xX*<#uZhwC5^7B9|Tx9)k*_o z?|qr{;fQ3wIvHOUv)n^$a~|0q+PA}Y3JVYO2a}DhRu;`x=a=wKDX?9W@pN&cd>^B| zaGlA8!(H)`H^q~Sg^n+{pTd@Q@CFa_%Gahpm406SvF*Z<-M{R3dF8#X=iEA6_VeK% zjaC8WjGhRM(re!j$bUM_8FbL$_{R4)TY}i{AC`O4K6#(c0ZFl_70h2`z8y6@pv3Y} zE6O*9lUZ@!-nQD0%NE9DiD@=}UfJ58eBD?0xNBzeN2zbe7)@3^*rnfZtoO%r>JfL_|*jr*Bsipx}7^AVb{9%raEgh9_`#yP_6Ug*7x^@lll7?nSZ@}STaSPFT;JQ zSs$Z*@`d-jHih2t%DeUVPvt*XuqySzovTMBB_uhn|5E??Q0w-0UuQcDHmBmC?}yfw zSavG&@5$WdYi98MtNzpG@3w3^S5`mxrEc+`_eAUY$9qJUcU}+bsc$@fqtxV$`OE4D zO_#R6|GNLN*3I?aHm?Qo(^gS!lcDnQF5~z^%boFyt=akR{ E05?g`{{R30 diff --git a/Projectiles/Summon/ViridVanguardBladeAlt.png b/Projectiles/Summon/ViridVanguardBladeAlt.png deleted file mode 100644 index 127ec26b1c56df6c4e67a5dc6dde181069221259..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2750 zcmV;v3PJUWP)41^@s6mDa4I00001b5ch_0Itp) z=>PxVA6O8Tn`(tYJVN;x7$51r5C;>&Nk*bQORLY`6iqw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)844MBoMVAntRiHPc%~0H~p95NHiX5R-L!(65cWxJt zvKcX)KP$0ZLt{E+&ReEi4X5Z4;u}rMrIkvCiX5T;0eF4Ffl!e@YybcN07*qoM6N<$ Ef-_w(*#H0l diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index 0ac1ae059b..094d79ac25 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -615,7 +615,8 @@ namespace CalamityMod } // Cached for efficiency purposes. - internal static readonly FieldInfo UImageFieldMisc = typeof(MiscShaderData).GetField("_uImage1", BindingFlags.NonPublic | BindingFlags.Instance); + internal static readonly FieldInfo UImageFieldMisc0 = typeof(MiscShaderData).GetField("_uImage0", BindingFlags.NonPublic | BindingFlags.Instance); + internal static readonly FieldInfo UImageFieldMisc1 = typeof(MiscShaderData).GetField("_uImage1", BindingFlags.NonPublic | BindingFlags.Instance); internal static readonly FieldInfo UImageFieldArmor = typeof(ArmorShaderData).GetField("_uImage", BindingFlags.NonPublic | BindingFlags.Instance); /// @@ -623,9 +624,17 @@ namespace CalamityMod /// /// The shader to bind the texture to. /// The texture to bind. - public static MiscShaderData SetShaderTexture(this MiscShaderData shader, Asset texture) + public static MiscShaderData SetShaderTexture(this MiscShaderData shader, Asset texture, int index = 1) { - UImageFieldMisc.SetValue(shader, texture); + switch (index) + { + case 0: + UImageFieldMisc0.SetValue(shader, texture); + break; + case 1: + UImageFieldMisc1.SetValue(shader, texture); + break; + } return shader; }