diff --git a/Buffs/DamageOverTime/SagePoison.cs b/Buffs/DamageOverTime/SagePoison.cs index 61879513b7..27cbd603f0 100644 --- a/Buffs/DamageOverTime/SagePoison.cs +++ b/Buffs/DamageOverTime/SagePoison.cs @@ -1,6 +1,4 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.DataStructures; -using CalamityMod.NPCs; +using CalamityMod.DataStructures; using CalamityMod.Systems.Collections; using Terraria; using Terraria.ModLoader; @@ -15,6 +13,8 @@ namespace CalamityMod.Buffs.DamageOverTime SicknessDebuffScaling = 1, NPCLifeRegenMethod = SagePoisonPower }; + + public static float ViridVanguardPoisonMultiplier => 2; public static void SagePoisonPower(NPC npc, int buffType, ref int buffIndex, ref int damage) { // The base DoT is multiplied by the amount of Viral Sprouts you have when applied diff --git a/Buffs/Summon/ViridVanguardBuff.cs b/Buffs/Summon/ViridVanguardBuff.cs index 51ea3391d7..68ca32a558 100644 --- a/Buffs/Summon/ViridVanguardBuff.cs +++ b/Buffs/Summon/ViridVanguardBuff.cs @@ -1,4 +1,4 @@ -using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Summon; using Terraria.ModLoader; namespace CalamityMod.Buffs.Summon @@ -7,6 +7,6 @@ namespace CalamityMod.Buffs.Summon { protected override int MinionProjectileType => ModContent.ProjectileType(); - protected override ref bool MinionBool => ref BuffModdedOwner.ViridVanguard; + protected override ref bool MinionBool => ref BuffModdedOwner.viridVanguard; } } diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 18943430c8..d1af70651d 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -1547,7 +1547,11 @@ 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 ViridVanguardActiveAttackerThisFrame = false; + public float ViridVanguardRotation = 0; + public float ViridVanguardActiveCooldown = 0; + public float ViridVanguardRotationToAdd = 0; public bool sageSpirit = false; public bool fleshBall = false; public bool eyeOfNight = false; @@ -2013,6 +2017,17 @@ namespace CalamityMod.CalPlayer { DoGHeadHitCounter = 0; } + ViridVanguardActiveAttackerThisFrame = Main.projectile.Any(x => x.active && x.type == ModContent.ProjectileType() && x.owner == Player.whoAmI && x.ModProjectile().CurrentState == ViridVanguardBlade.ViridVanguardAIState.PhotonRipperZenithSlashes); + ViridVanguardRotation = MathHelper.WrapAngle(ViridVanguardRotation + ViridVanguardRotationToAdd); + ViridVanguardRotationToAdd = ViridVanguard.IdleCirclingSpeed; + + if (Player.HeldItem.type == ModContent.ItemType()) + { + if (ViridVanguardActiveCooldown > 0) + ViridVanguardActiveCooldown--; + } + else if (ViridVanguardActiveCooldown >= 0 && ViridVanguardActiveCooldown < ViridVanguard.ActiveAttackCooldown) + ViridVanguardActiveCooldown++; if (fleshKnuckles) Player.statLifeMax2 += 25; @@ -2703,7 +2718,7 @@ namespace CalamityMod.CalPlayer deathstareEyeball = false; witherBlossom = false; flowersOfMortality = false; - ViridVanguard = false; + viridVanguard = false; sageSpirit = false; fleshBall = false; eyeOfNight = false; diff --git a/Items/Weapons/Ranged/ScorchedEarth.cs b/Items/Weapons/Ranged/ScorchedEarth.cs index f41004aca0..878d0c7068 100644 --- a/Items/Weapons/Ranged/ScorchedEarth.cs +++ b/Items/Weapons/Ranged/ScorchedEarth.cs @@ -8,61 +8,62 @@ using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Ranged { public class ScorchedEarth : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - public static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Item/ScorchedEarthShot", 3); + public static readonly SoundStyle RocketShoot = new("CalamityMod/Sounds/Item/ScorpioShot") { Volume = 0.45f }; - private int counter = 0; + public static int OriginalUseTime = 60; + public static int TimeBetweenBursts = 10; + public static int ProjectilesPerBurst = 4; public override void SetDefaults() { + Item.damage = 500; + Item.DamageType = DamageClass.Ranged; + Item.useAnimation = Item.useTime = OriginalUseTime; + Item.shoot = ProjectileType(); + Item.shootSpeed = 15f; + Item.knockBack = 6.5f; + Item.width = 104; Item.height = 44; - Item.damage = 485; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 8; - Item.useAnimation = 32; // 4 shots in just over half a second - Item.reuseDelay = 60; // 1 second recharge - Item.useLimitPerAnimation = 4; - Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 8.7f; + Item.channel = true; + Item.noUseGraphic = true; + Item.useAmmo = AmmoID.Rocket; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.rare = ModContent.RarityType(); - Item.autoReuse = true; - Item.shootSpeed = 12.6f; - Item.shoot = ModContent.ProjectileType(); - Item.useAmmo = AmmoID.Rocket; + Item.useStyle = ItemUseStyleID.Shoot; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/DudFire") with { Volume = .4f, Pitch = -.9f, PitchVariance = 0.1f }; Item.Calamity().donorItem = true; } - // Consume two ammo per fire - public override bool CanConsumeAmmo(Item ammo, Player player) => counter % 2 == 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0; - public override Vector2? HoldoutOffset() => new Vector2(-30, 0); + // Spawning the holdout won't consume ammo. + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] != 0; + + // Makes the rotation of the mouse around the player sync in multiplayer. + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ProjectileType(), 0, 0f, player.whoAmI, -30); - if (counter == 0) - { - SoundEngine.PlaySound(ShootSound, position); - } + // We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out. + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); - counter++; - if (counter == 4) - counter = 0; return false; } public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(). AddRecipeGroup("AnyAdamantiteBar", 15). AddIngredient(10). AddIngredient(ItemID.FragmentSolar, 50). diff --git a/Items/Weapons/Summon/ViridVanguard.cs b/Items/Weapons/Summon/ViridVanguard.cs index 6c1376707e..2c7217deb6 100644 --- a/Items/Weapons/Summon/ViridVanguard.cs +++ b/Items/Weapons/Summon/ViridVanguard.cs @@ -3,6 +3,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using CalamityMod.Rarities; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -12,21 +13,60 @@ namespace CalamityMod.Items.Weapons.Summon public class ViridVanguard : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Summon"; - public const int HorizontalSlashChargeTime = 14; - public const float HorizontalSlashSpeed = 44f; + #region AI-Related Balancing Properties - public const int VerticalSlashChargeTime = 32; + public static float IdleCirclingSpeed => 0.0375f; + public static float AxeCirclingSpeedMultiplier => 3f; + public static float ActiveAttackCirclingSpeedMultiplier => 10f; - public const float VerticalSlashSpeed = 45f; + //The next three are the amount of times the sword does each attack before moving to the next one + public static int HorizontalSlashAmount => 7; + public static int VerticalPierceAmount => 5; + public static int StabAmount => 6; + /// + /// How long the player must wait after an active ends to start the next one + /// + public static int ActiveAttackCooldown => 300; + public static int ActiveAttackStartup => 90; + public static int ActiveAttackEndlag => 30; + /// + /// How many slashes each vanguard will do during the active + /// + public static int ActiveAttackSlashCount => 4; + #endregion + #region Damage Balancing Properties - public const float VerticalTeleportOffset = 850f; - public const int PierceChargeAttackCycleTime = 44; + //Sage Poison's damage is kept in the Sage Poison file + public static float ActiveAttackSlashDmgMult => 5f; - public const float MaxTargetingDistance = 1550f; + //Note: the following two only apply when not using the active attack + public static float AxeDmgMult => 1.25f; + public static float SwordDmgMult => 1f; + #endregion - public const int ChargesPerAttackCycle = 7; + + + private static Texture2D BladeOutline = null; + public static Texture2D GetBladeOutlineTex() + { + if (BladeOutline == null) + { + var texture = ModContent.Request("CalamityMod/Projectiles/Summon/ViridVanguardBlade").Value; + BladeOutline = new Texture2D(Main.graphics.GraphicsDevice, texture.Width, texture.Height); + + var BaseArray = new Color[BladeOutline.Width * BladeOutline.Height]; + var ColorArray = new Color[BladeOutline.Width * BladeOutline.Height]; + texture.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f); + } + BladeOutline.SetData(ColorArray); + } + return BladeOutline; + } public override void SetStaticDefaults() { @@ -37,7 +77,7 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 26; Item.height = 36; - Item.damage = 73; + Item.damage = 60; Item.DamageType = DamageClass.Summon; Item.mana = 10; Item.useAnimation = Item.useTime = 14; @@ -52,22 +92,43 @@ namespace CalamityMod.Items.Weapons.Summon Item.shoot = ModContent.ProjectileType(); Item.rare = ModContent.RarityType(); } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - player.AddBuff(Item.buffType, 2); - var minion = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); - minion.originalDamage = Item.damage; - minion.ModProjectile().BladeIndex = player.ownedProjectileCounts[type]; - - int bladeIndex = 0; - foreach (Projectile pro in Main.ActiveProjectiles) + float totalSlots = 0f; + foreach (Projectile p in Main.ActiveProjectiles) { - if (pro.type == type && pro.owner == player.whoAmI) + if (p.minion && p.owner == player.whoAmI) { - pro.ModProjectile().BladeIndex = bladeIndex++; - pro.ModProjectile().AITimer = 0f; - pro.netUpdate = true; + totalSlots += p.minionSlots; + } + } + if (totalSlots >= player.maxMinions) + { + foreach (Projectile pro in Main.ActiveProjectiles) + { + if (pro.type == type && pro.owner == player.whoAmI && pro.ModProjectile().ActiveTimer == 0) + { + pro.ModProjectile().BeginSuperEpicPhotonRipperZenithKnockoffAttack(); + } + } + } + else + { + player.AddBuff(Item.buffType, 2); + + var minion = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); + minion.ModProjectile().BladeIndex = player.ownedProjectileCounts[type]; + + int bladeIndex = 0; + foreach (Projectile pro in Main.ActiveProjectiles) + { + if (pro.type == type && pro.owner == player.whoAmI) + { + pro.ModProjectile().BladeIndex = bladeIndex++; + pro.ModProjectile().ActiveTimer = ViridVanguard.ActiveAttackCooldown; + pro.ModProjectile().AITimer = 0f; + pro.netUpdate = true; + } } } return false; @@ -75,6 +136,8 @@ namespace CalamityMod.Items.Weapons.Summon public override void AddRecipes() { CreateRecipe(). + AddIngredient(). + AddIngredient(). AddIngredient(15). AddTile(TileID.MythrilAnvil). Register(); diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 9855a6c0b5..0b8b7a6a0b 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -1044,8 +1044,9 @@ ScorchedEarth: { DisplayName: Scorched Earth Tooltip: ''' - Fires a burst of four fuel-air rockets which explode into cluster bombs - Each burst consumes two rockets each + Fires a burst of four heat seeking missiles that rapidly accelerate after a short delay + All rockets explode into napalm cluster bombs on impact + 50% chance to save ammo 'Burns your targets to a fine crisp' ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 48d81d6a50..5209287f08 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -861,7 +861,15 @@ ViralSprout: { ViridVanguard: { DisplayName: Virid Vanguard - Tooltip: Summons a circular formation of blades that slice nearby enemies to pieces + Tooltip: + ''' + Alternates between summoning axes and swords, both laced with a powerful poison + Axes orbit the player, dealing high damage at a close range + Swords chase down enemies with extreme precision, tearing them to shreds + All weapons inflict Sage Poison, which becomes more powerful the more weapons are summoned + When all minion slots are full, again to spin up a flurry of slashes aimed at your cursor + This ability has a five-second cooldown that requires holding this item + ''' } VoidConcentrationStaff: { diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index e7a674c92d..c399a3778c 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -175,7 +175,6 @@ RicoshotCoin.DisplayName: Ricoshot Coin RocketFire.DisplayName: Fire RubberMortarRoundProj.DisplayName: Rubber Mortar SandblasterBullet.DisplayName: Sandstorm -ScorchedEarthBlast.DisplayName: Earth Scorcher ScorchedEarthClusterBomb.DisplayName: Cluster Bomb ScorchedEarthRocket.DisplayName: Rocket ScorpioRocket.DisplayName: Nano Missile diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index e612aa2d03..6b71d81ddb 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -74,7 +74,7 @@ namespace CalamityMod.NPCs.DevourerofGods global.unbreakableDR = true; NPC.chaseable = false; } - NPC.LifeMaxNERB(750000, 900000, 1500000); + NPC.LifeMaxNERB(760000, 910000, 1500000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -149,19 +149,20 @@ namespace CalamityMod.NPCs.DevourerofGods if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; - if (NPC.life > Main.npc[(int)NPC.ai[1]].life) - NPC.life = Main.npc[(int)NPC.ai[1]].life; + NPC.life = Main.npc[(int)NPC.ai[2]].life; + NPC.lifeMax = Main.npc[(int)NPC.ai[2]].lifeMax;NPC.life = NPC.lifeMax; // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; + float lifeRatio = Main.npc[(int)NPC.ai[2]].life / (float)Main.npc[(int)NPC.ai[2]].lifeMax; bool phase2 = lifeRatio < 0.65f; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (phase2) + if (phase2 && !phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60) { + phase2Started = true; // Once before DoG spawns, set new size @@ -264,7 +265,7 @@ namespace CalamityMod.NPCs.DevourerofGods // Decide segment offset stuff. NPC.rotation = directionToNextSegment.ToRotation() + MathHelper.PiOver2; - NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * NPC.width; + NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * (phase2Started ? 80 : NPC.width ); NPC.spriteDirection = (directionToNextSegment.X > 0).ToDirectionInt(); // Velocity variables diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index fcf697e9b4..324903100e 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -42,11 +42,9 @@ using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.Events; using Terraria.GameContent.ItemDropRules; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using static System.Net.Mime.MediaTypeNames; namespace CalamityMod.NPCs.DevourerofGods { @@ -291,6 +289,8 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.Calamity().VulnerableToElectricity = true; NPC.Calamity().VulnerableToSickness = false; + + NPC.life = NPC.lifeMax; } public override void BossHeadSlot(ref int index) @@ -538,9 +538,6 @@ namespace CalamityMod.NPCs.DevourerofGods // Continuously reset certain things. AttemptingToEnterPortal = false; - // Worm variable - if (NPC.ai[2] > 0f) - NPC.realLife = (int)NPC.ai[2]; // Despawn if (player.dead) diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index 5ab1ead78d..7e785a3b8e 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -70,7 +70,7 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.width = 66; NPC.height = 66; NPC.defense = 50; - NPC.LifeMaxNERB(750000, 900000, 1500000); + NPC.LifeMaxNERB(760000, 910000, 1500000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -152,30 +152,26 @@ namespace CalamityMod.NPCs.DevourerofGods if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; - if (NPC.life > Main.npc[(int)NPC.ai[1]].life) - NPC.life = Main.npc[(int)NPC.ai[1]].life; + NPC.life = Main.npc[(int)NPC.ai[2]].life; + NPC.lifeMax = Main.npc[(int)NPC.ai[2]].lifeMax; + // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; + float lifeRatio = Main.npc[(int)NPC.ai[2]].life / (float)Main.npc[(int)NPC.ai[2]].lifeMax; bool phase2 = lifeRatio < 0.65f; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (phase2) + if (phase2 && !phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60) { phase2Started = true; - - // Once before DoG spawns, set new size - if (Main.npc[(int)NPC.ai[2]].localAI[2] == 60f) - { NPC.position = NPC.Center; NPC.width = (int)(80 * NPC.scale); - NPC.height = (int)(140 * NPC.scale); + NPC.height = (int)(80 * NPC.scale); NPC.frame = new Rectangle(0, 0, 86, 148); NPC.position -= NPC.Size * 0.5f; NPC.ForceNetUpdate(false); - } } if (invinceTime > 0) diff --git a/Projectiles/Ranged/RocketFire.cs b/Projectiles/Ranged/RocketFire.cs index 899990b1ac..e6b3ee1246 100644 --- a/Projectiles/Ranged/RocketFire.cs +++ b/Projectiles/Ranged/RocketFire.cs @@ -1,4 +1,6 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,11 +13,11 @@ namespace CalamityMod.Projectiles.Ranged public override string Texture => "CalamityMod/Projectiles/Rogue/TotalityFire"; private bool initialized = false; + public static Asset Glow; public override void SetStaticDefaults() { Main.projFrames[Type] = 3; ProjectileID.Sets.TrailCacheLength[Type] = 2; - ProjectileID.Sets.TrailingMode[Type] = 0; } public override void SetDefaults() @@ -60,7 +62,6 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.frame = 0; } - //movement if (Projectile.velocity.X != Projectile.velocity.X) { @@ -99,9 +100,9 @@ namespace CalamityMod.Projectiles.Ranged } //dust - if (Main.rand.NextBool(4)) + if (Main.rand.NextBool(3)) { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, default, 1f); + int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool() ? DustID.Torch : Main.rand.NextBool() ? 53 : 54, 0f, 0f, 100, default, 1f); Dust dust = Main.dust[fire]; dust.position.X -= 2f; dust.position.Y += 2f; @@ -109,9 +110,9 @@ namespace CalamityMod.Projectiles.Ranged dust.noGravity = true; dust.velocity.Y -= 2f; } - if (Main.rand.NextBool(10)) + if (Main.rand.NextBool(6)) { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, 0f, 0f, 100, default, 1f); + int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, Main.rand.NextBool() ? DustID.Torch : Main.rand.NextBool() ? 53 : 54, 0f, 0f, 100, default, 1f); Dust dust = Main.dust[fire]; dust.position.X -= 2f; dust.position.Y += 2f; @@ -120,6 +121,17 @@ namespace CalamityMod.Projectiles.Ranged dust.velocity *= 0.1f; } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.Daybreak, 300); + target.AddBuff(BuffID.Oiled, 300); + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(BuffID.Daybreak, 300); + target.AddBuff(BuffID.Oiled, 300); + } public override bool OnTileCollide(Vector2 oldVelocity) { diff --git a/Projectiles/Ranged/ScorchedEarthBlast.cs b/Projectiles/Ranged/ScorchedEarthBlast.cs deleted file mode 100644 index 7673ef7306..0000000000 --- a/Projectiles/Ranged/ScorchedEarthBlast.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class ScorchedEarthBlast : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - private static int Lifetime = 20; - private static float ExplosionRadius = 150f; - private static float StartDustQuantity = 36f; - - public override void SetDefaults() - { - // Width and height don't actually do anything because the explosion uses custom collision - Projectile.width = Projectile.height = 300; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.penetrate = -1; - Projectile.timeLeft = Lifetime; - - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - // localAI[0] = frame counter - // localAI[1] = dust quantity - public override void AI() - { - // Play sound on frame 1 and initialize dust quantity - if (Projectile.localAI[0] == 0f) - { - Projectile.localAI[1] = StartDustQuantity; - } - - // Pure dust projectile - DrawProjectile(); - - // Increment frame counter - Projectile.localAI[0] += 1f; - } - - private void DrawProjectile() - { - // Taper down the dust amount for the last bit of the projectile's life - if (Projectile.localAI[0] >= Lifetime - 15) - Projectile.localAI[1] -= 1f; - - int dustCount = (int)Projectile.localAI[1]; - for (int i = 0; i < dustCount; ++i) - { - int dustType = Main.rand.NextBool() ? 6 : 244; - float scale = Main.rand.NextFloat(2.0f, 2.5f); - float randX = Main.rand.NextFloat(-30f, 30f); - float randY = Main.rand.NextFloat(-30f, 30f); - float randVelocity = Main.rand.NextFloat(5f, 19f); - float speed = (float)Math.Sqrt((double)(randX * randX + randY * randY)); - speed = randVelocity / speed; - randX *= speed; - randY *= speed; - int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType); - Main.dust[idx].position.X = Projectile.Center.X + Main.rand.NextFloat(-10f, 10f); - Main.dust[idx].position.Y = Projectile.Center.Y + Main.rand.NextFloat(-10f, 10f); - Main.dust[idx].velocity.X = randX; - Main.dust[idx].velocity.Y = randY; - Main.dust[idx].scale = scale; - Main.dust[idx].noGravity = true; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(BuffID.Daybreak, 300); - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius, targetHitbox); - } -} diff --git a/Projectiles/Ranged/ScorchedEarthClusterBomb.cs b/Projectiles/Ranged/ScorchedEarthClusterBomb.cs index 2127a50d88..c81b851c14 100644 --- a/Projectiles/Ranged/ScorchedEarthClusterBomb.cs +++ b/Projectiles/Ranged/ScorchedEarthClusterBomb.cs @@ -1,4 +1,6 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -8,6 +10,7 @@ namespace CalamityMod.Projectiles.Ranged public class ScorchedEarthClusterBomb : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; + public Vector2 vibrate = Vector2.Zero; public override void SetDefaults() { Projectile.width = 14; @@ -27,14 +30,25 @@ namespace CalamityMod.Projectiles.Ranged Projectile.velocity *= 0.95f; if (Projectile.velocity.Length() < 0.5f && Projectile.timeLeft > 10) Projectile.timeLeft = 10; + if (Projectile.timeLeft <= 75) + { + float power = 2.5f; + vibrate = Main.rand.NextVector2Circular(power, power); + } } public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - for (int i = 0; i < 10; i++) + SoundEngine.PlaySound(SoundID.Item62 with { Volume = 0.8f , MaxInstances = 3}, Projectile.position); + for (int i = 0; i < 15; i++) { - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 0, default, 1f); + int size = 16; + Vector2 position = Projectile.Center; + Vector2 velocity = Main.rand.NextVector2Circular(size, size); + SquishyLightParticle energy = new(position, velocity, Main.rand.NextFloat(0.2f, 0.3f), Color.DarkOrange * 0.5f, Main.rand.Next(6, 9), 1, 1.5f); + GeneralParticleHandler.SpawnParticle(energy); + Dust dust = Dust.NewDustPerfect(position, DustID.Torch, velocity, 0, default, Main.rand.NextFloat(1f, 2f)); + dust.noGravity = true; } int projAmt = Main.rand.Next(2, 4); if (Projectile.owner == Main.myPlayer) @@ -46,5 +60,15 @@ namespace CalamityMod.Projectiles.Ranged } } } + public override bool PreDraw(ref Color lightColor) + { + Texture2D Texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle frame = Texture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Vector2 drawPosition; + Vector2 origin = frame.Size() * 0.5f; + drawPosition = Projectile.Center - Main.screenPosition; + Main.EntitySpriteDraw(Texture, drawPosition + vibrate, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + return false; + } } } diff --git a/Projectiles/Ranged/ScorchedEarthHoldout.cs b/Projectiles/Ranged/ScorchedEarthHoldout.cs new file mode 100644 index 0000000000..67d1515ac0 --- /dev/null +++ b/Projectiles/Ranged/ScorchedEarthHoldout.cs @@ -0,0 +1,109 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; +using static CalamityMod.Items.Weapons.Ranged.ScorchedEarth; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ScorchedEarthHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ItemType(); + public override Vector2 GunTipPosition => base.GunTipPosition - Vector2.UnitY.RotatedBy(Projectile.rotation) * 5f * Projectile.spriteDirection * Owner.gravDir; + public override float RecoilResolveSpeed => 0.1f; + public override float MaxOffsetLengthFromArm => 15f; + public override float OffsetXUpwards => -12f; + public override float OffsetXDownwards => 2f; + public override float BaseOffsetY => -10f; + public override float OffsetYDownwards => 10f; + + public ref float ShootingTimer => ref Projectile.ai[0]; + public ref float TimerBetweenBursts => ref Projectile.ai[1]; + + public override void HoldoutAI() + { + + if (ShootingTimer >= HeldItem.useAnimation) + { + // Shooting the burst of rockets. + // The time is adapted to the speed modifier from the reforge. + int adaptedTimeBetweenBursts = TimeBetweenBursts * HeldItem.useAnimation / OriginalUseTime; + + if (ShootingTimer % adaptedTimeBetweenBursts == 0f) + ShootRocket(HeldItem, false); + + // Resets the timers when everything has been shot. + if (ShootingTimer >= HeldItem.useAnimation + adaptedTimeBetweenBursts * (ProjectilesPerBurst - 1)) + { + ShootingTimer = 0f; + TimerBetweenBursts = 0f; + } + if (Main.dedServ) + return; + Vector2 smokeVel = new Vector2(0, -8) * Main.rand.NextFloat(0.1f, 1.1f); + Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel, Main.rand.NextBool() ? Color.DarkSlateGray : Color.DarkGray, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.3f, 0.6f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + GeneralParticleHandler.SpawnParticle(smoke); + //Visual request from the donor that I tried and didn't end up liking. This is commented and not deleted in case the donor really wants this effect + //for (int i = 0; i < 2; i++) + { + //Vector2 backsmokeVel = new Vector2(6, -2) * Main.rand.NextFloat(0.1f, 1.1f); + //Particle backsmoke = new HeavySmokeParticle(GunTipPosition + (-Projectile.velocity * 110f), -Projectile.velocity.SafeNormalize(Vector2.UnitY) * backsmokeVel, Main.rand.NextBool() ? Color.DarkSlateGray : Color.Black, Main.rand.Next(20, 30 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + //GeneralParticleHandler.SpawnParticle(backsmoke); + } + } + + ShootingTimer++; + } + + public void ShootRocket(Item item, bool isRMB) + { + // We use the velocity of this projectile as its direction vector. + Vector2 projectileVelocity = Projectile.velocity.SafeNormalize(Vector2.Zero); + + // Every time we shoot we use ammo. + // With this method we also use the item's stats, like the shoot speed, or the type of ammo it was used. + Owner.PickAmmo(item, out _, out float projSpeed, out int damage, out float knockback, out int rocketType, Main.rand.Next(100) > 50); // 50% ammo conservation + + // Spawns the projectile. + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 12; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(10f)), ModContent.ProjectileType(), damage, knockback, Projectile.owner, rocketType); + + // Inside here go all the things that dedicated servers shouldn't spend resources on. + // Like visuals and sounds. + if (Main.dedServ) + return; + SoundEngine.PlaySound(RocketShoot with { Pitch = 0.045f }, Projectile.Center); + + // By decreasing the offset length of the gun from the arms, we give an effect of recoil. + OffsetLengthFromArm -= 7f; + + Particle shootPulse = new DirectionalPulseRing(GunTipPosition,Vector2.Zero,Color.Gray * 0.7f,new Vector2(0.5f, 1f),Projectile.rotation, 0.1f, 0.4f, 25); + GeneralParticleHandler.SpawnParticle(shootPulse); + for (int i = 0; i <= 8; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition, Main.rand.NextBool(3) ? 303 : 244, (shootVelocity * Main.rand.NextFloat(0.2f, 1.1f)).RotatedByRandom(0.4f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.8f, 1.4f); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } + } +} diff --git a/Projectiles/Ranged/ScorchedEarthRocket.cs b/Projectiles/Ranged/ScorchedEarthRocket.cs index d806b0180c..5aa1a6b15f 100644 --- a/Projectiles/Ranged/ScorchedEarthRocket.cs +++ b/Projectiles/Ranged/ScorchedEarthRocket.cs @@ -1,4 +1,7 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -8,123 +11,218 @@ namespace CalamityMod.Projectiles.Ranged public class ScorchedEarthRocket : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; + public int time = 0; + public bool BonusEffectMode; + public bool HasHit = false; + public bool SetLifetime = false; + public static readonly SoundStyle RocketExplosion = new("CalamityMod/Sounds/Item/AnomalysNanogunMPFBExplosion"); + public ref float RocketID => ref Projectile.ai[0]; + public override void SetStaticDefaults() { Main.projFrames[Type] = 10; ProjectileID.Sets.CultistIsResistantTo[Type] = true; - ProjectileID.Sets.TrailCacheLength[Type] = 3; - ProjectileID.Sets.TrailingMode[Type] = 0; } public override void SetDefaults() { - Projectile.width = 22; - Projectile.height = 22; + Projectile.width = Projectile.height = 34; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.penetrate = 1; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Ranged; - Projectile.tileCollide = false; - Projectile.extraUpdates = 1; } public override void AI() { - //Lighting - Lighting.AddLight(Projectile.Center, 1f, 0.79f, 0.3f); - - //Animation - Projectile.frameCounter++; - if (Projectile.frameCounter > (Projectile.frame == 1 ? 10 : 7)) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } + //Rotation + Projectile.rotation = Projectile.velocity.ToRotation(); + //If the frame ever goes over 10, return it to 6 if (Projectile.frame >= Main.projFrames[Type]) { Projectile.frame = 6; } + //For the first 20 frames, the rocket constantly loses velocity and stays on frame 0 + if (time <= 20) + { + Projectile.velocity *= 0.9f; + Projectile.frame = 0; + Projectile.frameCounter = 0; + } + //Ensures the prime sound only plays once + if (time == 24) + { + SoundStyle PrimeSound = new("CalamityMod/Sounds/Item/ScorchedEarthShot", 3) { Volume = 0.25f, MaxInstances = 8 }; + SoundEngine.PlaySound(PrimeSound with { Pitch = -0.1f }, Projectile.Center); + } + //Be VERY CAREFUL changing this. The rocket quickly gains speed for a very limited amount of time to make sure it doesn't go too fast + if (time > 24 && time < 34) + { + Projectile.velocity *= 1.5f; + } + //All of these effects only trigger once the rocket is speeding up + if (time >= 24) + { + //Lighting + Lighting.AddLight(Projectile.Center, 1f, 0.79f, 0.3f); + Projectile.frameCounter++; + if (Projectile.frameCounter >= 5) + { + Projectile.frameCounter = 0; + Projectile.frame++; + if (Projectile.frame >= Main.projFrames[Type]) + { + Projectile.frame = 6; + } + } + } + //After the rocket has reached full speed, give it homing for half a second + if (time >= 37 && time < 67) + { + CalamityUtils.HomeInOnNPC(Projectile, true, 350f, 20f, 6f); + } + //Handling Tile Breaking/Liquid Rockets + BonusEffectMode = Projectile.ai[2] == 2; + if (BonusEffectMode) + { + if (!SetLifetime) + { + Projectile.timeLeft = 60; + Projectile.extraUpdates = 0; + Projectile.damage = 0; + Projectile.alpha = 255; + SetLifetime = true; + } + if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII) + { - CalamityUtils.HomeInOnNPC(Projectile, true, 400f, 5f, 30f); + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID); + int blastRadius = (int)(Projectile.RocketBehavior(info) * 3f); + if (time % 5 == 0) + { + Projectile.ExplodeTiles((int)(blastRadius * Utils.Remap(time, 60f, 1f, 1f, 0f, true)), info.respectStandardBlastImmunity, info.tilesToCheck, info.wallsToCheck); + } + } + else + { + Point center = Projectile.Center.ToTileCoordinates(); + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID); + int blastRadius = Projectile.RocketBehavior(info); + if (RocketID == ItemID.DryRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(time, 60f, 1f, 1f, 0f, true); + if (time == 0) + { + Utils.PlotTileArea(center.X * blastRadius, center.Y * blastRadius, DelegateMethods.SpreadDry); + } + } + if (RocketID == ItemID.WetRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(time, 60f, 1f, 1f, 0f, true); + if (time == 0) + { + Utils.PlotTileArea(center.X * blastRadius, center.Y * blastRadius, DelegateMethods.SpreadWater); + } + } + if (RocketID == ItemID.LavaRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(time, 60f, 1f, 1f, 0f, true); + if (time == 0) + { + Utils.PlotTileArea(center.X * blastRadius, center.Y * blastRadius, DelegateMethods.SpreadLava); + } + } + if (RocketID == ItemID.HoneyRocket) + { + DelegateMethods.f_1 = 10.5f * Utils.Remap(time, 60f, 1f, 1f, 0f, true); + if (time == 0) + { + Utils.PlotTileArea(center.X * blastRadius, center.Y * blastRadius, DelegateMethods.SpreadHoney); + } + } + } + } + time++; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + HasHit = true; + } - //Rotation - Projectile.rotation = Projectile.velocity.ToRotation(); + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + HasHit = true; + } - float xVel = Projectile.velocity.X * 0.5f; - float yVel = Projectile.velocity.Y * 0.5f; - int d = Dust.NewDust(new Vector2(Projectile.position.X + 3f + xVel, Projectile.position.Y + 3f + yVel) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, DustID.CopperCoin, 0f, 0f, 100, default, 1f); - Main.dust[d].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[d].velocity *= 0.2f; - Main.dust[d].noGravity = true; - d = Dust.NewDust(new Vector2(Projectile.position.X + 3f + xVel, Projectile.position.Y + 3f + yVel) - Projectile.velocity * 0.5f, Projectile.width - 8, Projectile.height - 8, DustID.CopperCoin, 0f, 0f, 100, default, 0.5f); - Main.dust[d].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[d].velocity *= 0.05f; + public override bool OnTileCollide(Vector2 oldVelocity) + { + HasHit = true; + return true; } public override void OnKill(int timeLeft) { - if (Projectile.owner == Main.myPlayer) + if (Projectile.owner == Main.myPlayer && HasHit == true && !BonusEffectMode && Projectile.ai[2] == 0) { - Projectile.ExpandHitboxBy(300); - SoundEngine.PlaySound(SoundID.Item14, Projectile.position); - - if (!Main.dedServ) - { - Vector2 goreSource = Projectile.Center; - int goreAmt = 10; - Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); - for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) - { - float velocityMult = 0.33f; - if (goreIndex < (goreAmt / 3)) - { - velocityMult = 0.66f; - } - if (goreIndex >= (2 * goreAmt / 3)) - { - velocityMult = 1f; - } - Mod mod = ModContent.GetInstance(); - int type = Main.rand.Next(61, 64); - int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - Gore gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y += 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X += 1f; - gore.velocity.Y -= 1f; - type = Main.rand.Next(61, 64); - smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); - gore = Main.gore[smoke]; - gore.velocity *= velocityMult; - gore.velocity.X -= 1f; - gore.velocity.Y -= 1f; - } - } - - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * 2f, Projectile.owner); - for (int j = 0; j < 5; j++) + bool isClusterRocket = (RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII); + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); + SoundEngine.PlaySound(RocketExplosion with { MaxInstances = 2}, Projectile.Center); + //If using a rocket with extra effects, spawn an invisible copy that handes the tile breaking/liquid spawning logic + if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII || RocketID == ItemID.DryRocket || RocketID == ItemID.WetRocket || RocketID == ItemID.LavaRocket || RocketID == ItemID.HoneyRocket) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner, RocketID, 0f, 2f); + // Create Blast + float blastSize = 300; + float minMultiplier = 0.25f; + int hitsToMinMult = 4; + int debuff1 = BuffID.Daybreak; + int debuff2 = BuffID.Oiled; + int debuffTime = 360; + //The explosion has a different damage scaling depending on which rocket type you have. Left is Cluster Rocket, right is Non-Cluster. + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * (isClusterRocket ? 0.75f : 1)), Projectile.knockBack, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.localAI[0] = debuff1; + blast.localAI[2] = debuff2; + blast.localAI[1] = debuffTime; + blast.timeLeft = 15; + blast.DamageType = DamageClass.Ranged; + for (int j = 0; j < (isClusterRocket ? 9 : 5); j++) { Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(8f, 10f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Projectile.owner); } + for (int i = 0; i < 15; i++) + { + Vector2 randVel = new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.8f, 1.6f); + Particle smoke = new HeavySmokeParticle(Projectile.Center + randVel, randVel, Color.Black, Main.rand.Next(20, 25 + 1), Main.rand.NextFloat(0.9f, 2.3f), 0.7f); + GeneralParticleHandler.SpawnParticle(smoke); + } + for (int i = 0; i < 2; i++) + { + //Explosion effect + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.OrangeRed : Color.DarkGoldenrod * 0.8f, "CalamityMod/Particles/ShineExplosion1", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.2f, 20, true, 1.4f); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.18f, 20, true, 1f); + GeneralParticleHandler.SpawnParticle(blastRing2); + Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Red, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1f, 1.8f, 25, true); + GeneralParticleHandler.SpawnParticle(blastRing3); + Particle blastRing4 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.8f, 25, true); + GeneralParticleHandler.SpawnParticle(blastRing4); + Particle blastRing5 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.13f, 20, true, 1f); + GeneralParticleHandler.SpawnParticle(blastRing5); + } } } - public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + if (time < 1) + return false; + Texture2D Texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Rectangle frame = Texture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); + Vector2 drawPosition; + Vector2 origin = frame.Size() * 0.5f; + + drawPosition = Projectile.Center - Main.screenPosition; + Main.EntitySpriteDraw(Texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); return false; } } diff --git a/Projectiles/Summon/ViridVanguardBlade.cs b/Projectiles/Summon/ViridVanguardBlade.cs index ce229a590f..eec31f918a 100644 --- a/Projectiles/Summon/ViridVanguardBlade.cs +++ b/Projectiles/Summon/ViridVanguardBlade.cs @@ -1,7 +1,10 @@ using System; +using System.Collections.Generic; using System.IO; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.Summon; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Particles; using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -23,6 +26,10 @@ namespace CalamityMod.Projectiles.Summon HorizontalSlashes, VerticalPierceTeleport, RegularPierceSlashes, + ChargingCircle, + PhotonRipperZenithSlashes, + PhotonRipperZenithEndlag, + AxeCircle } public int BladeIndex; @@ -31,15 +38,15 @@ namespace CalamityMod.Projectiles.Summon public Vector2 ChargeStartingPosition; + public float BladeAngleForPhripperZenith = 0; + + public int CurrentViridCount => (int)MathHelper.Max(1, Owner.ownedProjectileCounts[Type]); + public float BladeHoverOffsetAngle { get { - float projectileCounts = Owner.ownedProjectileCounts[Type]; - if (projectileCounts <= 1f) - projectileCounts = 1f; - - return MathHelper.TwoPi * BladeIndex / projectileCounts + AITimer / 27f; + return MathHelper.TwoPi * BladeIndex / CurrentViridCount + Owner.Calamity().ViridVanguardRotation; } } @@ -49,15 +56,51 @@ namespace CalamityMod.Projectiles.Summon set => Projectile.ai[0] = (int)value; } + public static List ActiveAttackStateList = new() { ViridVanguardAIState.ChargingCircle, ViridVanguardAIState.PhotonRipperZenithSlashes, ViridVanguardAIState.PhotonRipperZenithEndlag }; + + public Player Owner => Main.player[Projectile.owner]; public ref float AITimer => ref Projectile.ai[1]; + public float ActiveTimer + { + get => Owner.Calamity().ViridVanguardActiveCooldown; + set => Owner.Calamity().ViridVanguardActiveCooldown = value; + } + + public bool IsAxe => BladeIndex % 2 == 0; + + public bool DrawAsAxe => IsInDotRange && CurrentState == ViridVanguardAIState.PhotonRipperZenithSlashes ? !ActiveAttacking : IsAxe; + + bool IsInDotRange = false; + + bool ActiveAttacking = false; + + Vector2 StoredAttackMousePos = Vector2.Zero; + public ref float BladeGleamInterpolant => ref Projectile.localAI[0]; + #region AI consts + public const int HorizontalSlashChargeTime = 14; + + public const float HorizontalSlashSpeed = 44f; + + public const int VerticalSlashChargeTime = 32; + + public const float VerticalSlashSpeed = 45f; + + public const float VerticalTeleportOffset = 850f; + + public const int PierceChargeAttackCycleTime = 44; + + public const float MaxTargetingDistance = 1550f; + + + #endregion + public override void SetStaticDefaults() { - Main.projPet[Type] = true; ProjectileID.Sets.MinionSacrificable[Type] = true; ProjectileID.Sets.MinionTargettingFeature[Type] = true; ProjectileID.Sets.TrailingMode[Type] = 2; @@ -66,8 +109,8 @@ namespace CalamityMod.Projectiles.Summon public override void SetDefaults() { - Projectile.width = 84; - Projectile.height = 84; + Projectile.width = 120; + Projectile.height = 120; Projectile.netImportant = true; Projectile.friendly = true; Projectile.ignoreWater = true; @@ -108,7 +151,7 @@ namespace CalamityMod.Projectiles.Summon if (BladeGleamInterpolant <= 0.02f) BladeGleamInterpolant = 0f; - NPC potentialTarget = Projectile.Center.MinionHoming(ViridVanguard.MaxTargetingDistance, Owner); + NPC potentialTarget = Projectile.Center.MinionHoming(MaxTargetingDistance, Owner); switch (CurrentState) { case ViridVanguardAIState.CircleOwner: @@ -123,24 +166,43 @@ namespace CalamityMod.Projectiles.Summon case ViridVanguardAIState.RegularPierceSlashes: DoBehavior_RegularPierceSlashes(potentialTarget); break; + case ViridVanguardAIState.ChargingCircle: + DoBehavior_PhotonRipperZenithStartup(potentialTarget); + break; + case ViridVanguardAIState.PhotonRipperZenithSlashes: + DoBehavior_PhotonRipperZenithActive(potentialTarget); + break; + case ViridVanguardAIState.PhotonRipperZenithEndlag: + DoBehavior_PhotonRipperZenithEndlag(potentialTarget); + break; + case ViridVanguardAIState.AxeCircle: + DoBehavior_AxeCircle(potentialTarget); + break; } AITimer++; + if (CurrentState == ViridVanguardAIState.PhotonRipperZenithEndlag) + Projectile.MaxUpdates = 1; } public void DoBehavior_CircleOwner(NPC potentialTarget) { + //Reset active cooldown if it's in the negative somehow + if (ActiveTimer < 0) + ActiveTimer = ViridVanguard.ActiveAttackCooldown; + // Begin attacking if an enemy is nearby. + var viridAmount = 300f / CurrentViridCount; if (potentialTarget is not null) { - CurrentState = ViridVanguardAIState.HorizontalSlashes; + CurrentState = IsAxe ? ViridVanguardAIState.AxeCircle : 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); + float hoverDistMult = MathHelper.Lerp(IsAxe ? 170 : 200, IsAxe ? 200 : 170, (MathF.Sin(AITimer * 0.06f) + 1) * 0.5f); + Vector2 hoverDestination = Owner.Center + BladeHoverOffsetAngle.ToRotationVector2() * hoverDistMult; + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.04f).MoveTowards(hoverDestination, 20f); Projectile.velocity *= 0.8f; // Teleport to the owner if sufficiently far away. @@ -154,10 +216,35 @@ namespace CalamityMod.Projectiles.Summon Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; } + public void DoBehavior_AxeCircle(NPC potentialTarget) + { + // Begin attacking if an enemy is nearby. + var viridAmount = 300f / CurrentViridCount; + if (potentialTarget is null) + { + ReturnToIdleState(); + return; + } + var offset = MathHelper.TwoPi * MathF.Floor(BladeIndex * 0.5f) / MathF.Ceiling(CurrentViridCount * 0.5f) + Owner.Calamity().ViridVanguardRotation; + Vector2 hoverDestination = Owner.Center + offset.ToRotationVector2() * 200f; + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.04f).MoveTowards(hoverDestination, 32f); + Projectile.velocity *= 0.8f; + + // Teleport to the owner if sufficiently far away. + if (!Projectile.WithinRange(Owner.Center, 2500f)) + { + Projectile.Center = hoverDestination; + Projectile.netUpdate = true; + } + Owner.Calamity().ViridVanguardRotationToAdd = ViridVanguard.IdleCirclingSpeed * MathHelper.SmoothStep(1f, ViridVanguard.AxeCirclingSpeedMultiplier, AITimer / 150f); + // Aim away from the target. + Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; + } + public void DoBehavior_HorizontalSlashes(NPC target) { int hoverTime = 22; - int chargeTime = ViridVanguard.HorizontalSlashChargeTime; + int chargeTime = HorizontalSlashChargeTime; // Exit the attack state if the blade no longer has a valid target. if (target is null) @@ -197,15 +284,15 @@ namespace CalamityMod.Projectiles.Summon { 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() * ViridVanguard.HorizontalSlashSpeed; + Projectile.velocity = Vector2.UnitX * (target.Center.X > Projectile.Center.X).ToDirectionInt() * HorizontalSlashSpeed; Projectile.netUpdate = true; } // Switch to the next attack state once enough charges have happened. - if (AITimer >= (hoverTime + chargeTime) * ViridVanguard.ChargesPerAttackCycle) + if (AITimer >= (hoverTime + chargeTime) * ViridVanguard.HorizontalSlashAmount) { AITimer = 0f; - CurrentState = ViridVanguardAIState.VerticalPierceTeleport; + CurrentState = ViridVanguardAIState.RegularPierceSlashes; Projectile.netUpdate = true; } } @@ -213,7 +300,7 @@ namespace CalamityMod.Projectiles.Summon public void DoBehavior_VerticalPierceTeleport(NPC target) { int hoverTime = 26; - int chargeTime = ViridVanguard.VerticalSlashChargeTime; + int chargeTime = VerticalSlashChargeTime; // Exit the attack state if the blade no longer has a valid target. if (target is null) @@ -250,30 +337,30 @@ namespace CalamityMod.Projectiles.Summon { SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Pitch = 1.6f, Volume = 0.27f }, Projectile.Center); Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; - Projectile.velocity = Vector2.UnitY * ViridVanguard.VerticalSlashSpeed; + Projectile.velocity = Vector2.UnitY * VerticalSlashSpeed; Projectile.netUpdate = true; } // Teleport above the target once sufficiently far below them. - if (wrappedAttackTimer >= hoverTime + 5f && Projectile.Center.Y > target.Center.Y + ViridVanguard.VerticalTeleportOffset) + if (wrappedAttackTimer >= hoverTime + 5f && Projectile.Center.Y > target.Center.Y + VerticalTeleportOffset) { Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; - Projectile.Center = target.Center - Vector2.UnitY * ViridVanguard.VerticalTeleportOffset * 0.7f; + Projectile.Center = target.Center - Vector2.UnitY * VerticalTeleportOffset * 0.7f; Projectile.netUpdate = true; } // Switch to the next attack state once enough charges have happened. - if (AITimer >= (hoverTime + chargeTime) * ViridVanguard.ChargesPerAttackCycle) + if (AITimer >= (hoverTime + chargeTime) * ViridVanguard.VerticalPierceAmount) { AITimer = 0f; - CurrentState = ViridVanguardAIState.RegularPierceSlashes; + CurrentState = ViridVanguardAIState.HorizontalSlashes; Projectile.netUpdate = true; } } public void DoBehavior_RegularPierceSlashes(NPC target) { - int attackCycleTime = ViridVanguard.PierceChargeAttackCycleTime; + int attackCycleTime = PierceChargeAttackCycleTime; float upwardRiseTimeRatio = 0.4f; float pierceTimeRatio = 0.14f; @@ -286,14 +373,13 @@ namespace CalamityMod.Projectiles.Summon } // Initialize the starting position on the first frame. - int localAITimer = (int)AITimer + Projectile.identity; - if (localAITimer % attackCycleTime == 1f) + if (AITimer % attackCycleTime == 1f) { ChargeStartingPosition = Projectile.Center + Main.rand.NextVector2Circular(80f, 80f); Projectile.netUpdate = true; } - float attackCompletion = localAITimer / (float)attackCycleTime % 1f; + float attackCompletion = AITimer / (float)attackCycleTime % 1f; // Reset the trail point array if aiming at the target. if (attackCompletion < upwardRiseTimeRatio) @@ -323,21 +409,137 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity = Vector2.Zero; // Play a slice sound once ready to charge. - if (localAITimer % attackCycleTime == (int)(attackCycleTime * upwardRiseTimeRatio)) + if (AITimer % 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 * ViridVanguard.ChargesPerAttackCycle) + if (AITimer >= attackCycleTime * ViridVanguard.StabAmount) { AITimer = 0f; - CurrentState = ViridVanguardAIState.HorizontalSlashes; + CurrentState = ViridVanguardAIState.VerticalPierceTeleport; Projectile.netUpdate = true; } } + public void DoBehavior_PhotonRipperZenithStartup(NPC target) + { + Projectile.MaxUpdates = 2; + float completion = AITimer / (ViridVanguard.ActiveAttackStartup * (float)Projectile.MaxUpdates); + Vector2 hoverDestination = Owner.Center + BladeAngleForPhripperZenith.ToRotationVector2() * MathHelper.Lerp(200f, 116f, completion); + + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.04f).MoveTowards(hoverDestination, MathHelper.Lerp(16f, 64f, completion)); + Projectile.velocity *= 0.8f; + Owner.Calamity().ViridVanguardRotationToAdd = MathHelper.Lerp(1, ViridVanguard.ActiveAttackCirclingSpeedMultiplier, completion) * ViridVanguard.IdleCirclingSpeed; + BladeAngleForPhripperZenith += Owner.Calamity().ViridVanguardRotationToAdd / Projectile.MaxUpdates; + ActiveTimer = -1; + IsInDotRange = false; + + if (completion >= 1f) + { + CurrentState = ViridVanguardAIState.PhotonRipperZenithSlashes; + Projectile.netUpdate = true; + } + + // Aim away from the target. + Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; + } + public void DoBehavior_PhotonRipperZenithActive(NPC target) + { + Projectile.MaxUpdates = 2; + Vector2 angleToMouse = Owner.DirectionTo(IsInDotRange ? StoredAttackMousePos : Owner.Calamity().mouseWorld); + + float dotResult = Vector2.Dot(angleToMouse, BladeAngleForPhripperZenith.ToRotationVector2()); + + if (dotResult < -0.5f) + { + IsInDotRange = false; + ActiveAttacking = false; + } + else if (!IsInDotRange) + { + IsInDotRange = true; + StoredAttackMousePos = Owner.Calamity().mouseWorld; + ActiveTimer--; + + if (ActiveTimer % 2 == 0) + { + ActiveAttacking = true; + Projectile.ResetLocalNPCHitImmunity(); + } + } + dotResult += 1f; + dotResult /= 2f; + if (!ActiveAttacking) + { + Vector2 hoverDestination = Owner.Center + BladeAngleForPhripperZenith.ToRotationVector2() * 116f; + Projectile.Center = hoverDestination; + Projectile.velocity *= 0.8f; + + Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; + if ((ActiveTimer < -2 * ViridVanguard.ActiveAttackSlashCount * CurrentViridCount || ActiveTimer > 0) && Projectile.FinalExtraUpdate()) + { + CurrentState = ViridVanguardAIState.PhotonRipperZenithEndlag; + ActiveTimer = ViridVanguard.ActiveAttackCooldown; + AITimer = 0; + } + } + else + { + float distance = Owner.Distance(StoredAttackMousePos); + float endSize = MathHelper.Clamp(distance * 0.25f, 164f, 300f); + Vector2 hoverCenter = Vector2.Lerp(Owner.Center, Owner.Center + Owner.Center.DirectionTo(StoredAttackMousePos) * (distance > 164 ? distance - endSize : 0), dotResult); + Vector2 finalHoverDestination = hoverCenter + BladeAngleForPhripperZenith.ToRotationVector2() * MathHelper.Lerp(116f, endSize, dotResult); + Projectile.Center = finalHoverDestination; + Projectile.velocity *= 0.8f; + Projectile.rotation = Projectile.AngleFrom(hoverCenter) + MathHelper.PiOver2; + } + + Owner.Calamity().ViridVanguardRotationToAdd = ViridVanguard.ActiveAttackCirclingSpeedMultiplier * ViridVanguard.IdleCirclingSpeed; + BladeAngleForPhripperZenith += Owner.Calamity().ViridVanguardRotationToAdd / Projectile.MaxUpdates; + + } + public void DoBehavior_PhotonRipperZenithEndlag(NPC target) + { + + Projectile.MaxUpdates = 1; + float completion = 1 - AITimer / (ViridVanguard.ActiveAttackEndlag * (float)Projectile.MaxUpdates); + if (Owner.Calamity().ViridVanguardActiveAttackerThisFrame) + { + AITimer = 0; + ActiveTimer = ViridVanguard.ActiveAttackCooldown; + completion = 1; + } + Vector2 hoverDestination = Owner.Center + BladeAngleForPhripperZenith.ToRotationVector2() * MathHelper.Lerp(200f, 116f, completion); + Projectile.Center = hoverDestination; + Projectile.velocity *= 0.8f; + Owner.Calamity().ViridVanguardRotationToAdd = MathHelper.Lerp(1, ViridVanguard.ActiveAttackCirclingSpeedMultiplier, completion) * ViridVanguard.IdleCirclingSpeed; + BladeAngleForPhripperZenith += Owner.Calamity().ViridVanguardRotationToAdd / Projectile.MaxUpdates; + + if (completion <= 0f) + { + ReturnToIdleState(); + Owner.Calamity().ViridVanguardRotation += MathHelper.WrapAngle(BladeAngleForPhripperZenith - BladeHoverOffsetAngle); //This will cause the proper rotation to be kept on completion + Projectile.netUpdate = true; + } + + // Aim away from the target. + Projectile.rotation = Projectile.AngleFrom(Owner.Center) + MathHelper.PiOver2; + } + + public void BeginSuperEpicPhotonRipperZenithKnockoffAttack() + { + + if (CurrentState != ViridVanguardAIState.CircleOwner) + AITimer = 0f; + BladeAngleForPhripperZenith = BladeHoverOffsetAngle; + CurrentState = ViridVanguardAIState.ChargingCircle; + AITimer = 0f; + Projectile.netUpdate = true; + } public void ReturnToIdleState() { AITimer = 0f; + Projectile.extraUpdates = 0; CurrentState = ViridVanguardAIState.CircleOwner; Projectile.netUpdate = true; } @@ -348,25 +550,51 @@ namespace CalamityMod.Projectiles.Summon if (Projectile.type == ModContent.ProjectileType()) { if (Owner.dead) - Owner.Calamity().ViridVanguard = false; + Owner.Calamity().viridVanguard = false; - if (Owner.Calamity().ViridVanguard) + if (Owner.Calamity().viridVanguard) Projectile.timeLeft = 2; } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.Calamity().sagePoisonDamage = (int)(SagePoison.debuffData.EnemyLostRegen * SagePoison.ViridVanguardPoisonMultiplier * CurrentViridCount); + target.AddBuff(ModContent.BuffType(), 60); + if (ActiveAttacking) + { + Vector2 vel = new Vector2(0.1f, 0.1f).RotatedByRandom(100); + VoidSparkParticle spark2 = new VoidSparkParticle(target.Center, vel, false, 9, Main.rand.NextFloat(0.25f, 0.35f), Main.rand.NextBool() ? Color.LimeGreen : Color.Goldenrod); + GeneralParticleHandler.SpawnParticle(spark2); + SoundEngine.PlaySound(CommonCalamitySounds.SwiftSliceSound with { Volume = CommonCalamitySounds.SwiftSliceSound.Volume * 0.3f, MaxInstances = 0 }, Projectile.Center); + } + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + //Deals massively increased damage during the active attack + if (ActiveAttacking) + modifiers.SourceDamage *= ViridVanguard.ActiveAttackSlashDmgMult; + //when not using the active, deal the right amount of damage for the swords vs axes + else if (!ActiveAttackStateList.Contains(CurrentState)) + if (IsAxe) + modifiers.SourceDamage *= ViridVanguard.AxeDmgMult; + else + modifiers.SourceDamage *= ViridVanguard.SwordDmgMult; + } + public Color TrailColorFunction(float completionRatio) { - float opacity = (float)Math.Pow(Utils.GetLerpValue(1f, 0.45f, completionRatio, true), 4D) * Projectile.Opacity * 0.48f; + float opacity = (float)Math.Pow(Utils.GetLerpValue(1f, 0.45f, completionRatio, true), 4D) * Projectile.Opacity * (CurrentState == ViridVanguardAIState.CircleOwner ? 0.3f : 0.48f); 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 float TrailWidthFunction(float completionRatio) => Projectile.height * (1f - completionRatio) * (DrawAsAxe ? 0.6f : 0.8f); public override bool PreDraw(ref Color lightColor) { Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Rectangle frame = texture.Frame(2, 1, DrawAsAxe ? 0 : 1, 0); Vector2 origin = frame.Size() * 0.5f; Vector2 drawPosition = Projectile.Center - Main.screenPosition; SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; @@ -382,18 +610,34 @@ namespace CalamityMod.Projectiles.Summon Main.pixelShader.CurrentTechnique.Passes[0].Apply(); // Draw the blade. - Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation + 0.2f, origin, Projectile.scale, direction, 0); + float outlineOpacity = 1; + float outlineWidth = 1; + Color outlineColor = Color.LimeGreen; + if (!(ActiveAttackStateList.Contains(CurrentState) && ActiveTimer > 0)) + { + outlineWidth = Math.Clamp(MathF.Pow(1 - ActiveTimer / ViridVanguard.ActiveAttackCooldown, 3), 0, 1); + outlineOpacity = 0.75f; + } + var outlineTex = ViridVanguard.GetBladeOutlineTex(); + var rotation = Projectile.rotation + (DrawAsAxe ? -0.2f : 0.2f); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(2, 0) * outlineWidth, frame, outlineColor * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(0, 2) * outlineWidth, frame, outlineColor * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(-2, 0) * outlineWidth, frame, outlineColor * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(outlineTex, drawPosition + new Vector2(0, -2) * outlineWidth, frame, outlineColor * outlineOpacity, rotation, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), rotation, origin, Projectile.scale, direction, 0); // Draw the gleam at the tip of the blade. - 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); + if (ActiveTimer <= 0) + { + 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, since they're only defined once at load-time in vanilla. GameShaders.Misc["EmpressBlade"].UseImage0("Images/Extra_209"); GameShaders.Misc["EmpressBlade"].UseImage1("Images/Extra_210"); diff --git a/Projectiles/Summon/ViridVanguardBlade.png b/Projectiles/Summon/ViridVanguardBlade.png index e2cbaf2040..6621e5b1c6 100644 Binary files a/Projectiles/Summon/ViridVanguardBlade.png and b/Projectiles/Summon/ViridVanguardBlade.png differ