diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index c2cb36403b..c59657485c 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -524,7 +524,8 @@ namespace CalamityMod.CalPlayer public bool dodgeScarf = false; public bool evasionScarf = false; public bool badgeOfBravery = false; - public bool warbannerOfTheSun = false; + public bool WarbanneroftheRighteous = false; + public bool warbannerGlow = false; public bool tesla = false; public bool teslaVisuals = true; public bool cryogenSoul = false; @@ -1758,7 +1759,8 @@ namespace CalamityMod.CalPlayer bloodyWormTooth = false; vexation = false; badgeOfBravery = false; - warbannerOfTheSun = false; + WarbanneroftheRighteous = false; + warbannerGlow = false; aSpark = false; transformer = false; hideOfDeus = false; diff --git a/Cooldowns/WarbanneroftheSunBuff.png b/Cooldowns/WarbanneroftheRighteousBuff.png similarity index 100% rename from Cooldowns/WarbanneroftheSunBuff.png rename to Cooldowns/WarbanneroftheRighteousBuff.png diff --git a/Cooldowns/WarbanneroftheSunBuffOutline.png b/Cooldowns/WarbanneroftheRighteousBuffOutline.png similarity index 100% rename from Cooldowns/WarbanneroftheSunBuffOutline.png rename to Cooldowns/WarbanneroftheRighteousBuffOutline.png diff --git a/Cooldowns/WarbanneroftheSunBuffOverlay.png b/Cooldowns/WarbanneroftheRighteousBuffOverlay.png similarity index 100% rename from Cooldowns/WarbanneroftheSunBuffOverlay.png rename to Cooldowns/WarbanneroftheRighteousBuffOverlay.png diff --git a/Cooldowns/WarbanneroftheSunBuff.cs b/Cooldowns/WarbanneroftheSunBuff.cs index baf1815d94..78ddea9b66 100644 --- a/Cooldowns/WarbanneroftheSunBuff.cs +++ b/Cooldowns/WarbanneroftheSunBuff.cs @@ -14,19 +14,19 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Cooldowns { - public class WarbanneroftheSunBuff : CooldownHandler + public class WarbanneroftheRighteousBuff : CooldownHandler { - public float CompletionPercentage => Utils.GetLerpValue(40, 0, instance.timeLeft); + public float CompletionPercentage => Utils.GetLerpValue(80, 0, instance.timeLeft); private bool IsEmpty => CompletionPercentage == 0; - private float TextXOffset => (instance.timeLeft < 20 ? -11 : -18f); + private float TextXOffset => (instance.timeLeft <= 20 ? -11 : -18f); private Vector2 TextPosition => new(TextXOffset, 15); private Color TextColor => Color.White; private Color TextBorderColor => Color.Black; - public static new string ID => "WarbanneroftheSunBuff"; + public static new string ID => "WarbanneroftheRighteousBuff"; public override bool CanTickDown => false; public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); - public override bool ShouldDisplay => instance.player.Calamity().warbannerOfTheSun; + public override bool ShouldDisplay => instance.player.Calamity().WarbanneroftheRighteous; public override string Texture => "CalamityMod/Cooldowns/" + ID; public override Color CooldownStartColor => IsEmpty ? Color.DimGray : Color.Lerp(Color.SlateGray, Color.DarkGoldenrod, CompletionPercentage); diff --git a/Items/Accessories/WarbanneroftheRighteous.cs b/Items/Accessories/WarbanneroftheRighteous.cs new file mode 100644 index 0000000000..4c7faeeb79 --- /dev/null +++ b/Items/Accessories/WarbanneroftheRighteous.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.CalPlayer; +using CalamityMod.Cooldowns; +using CalamityMod.NPCs; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Mono.Cecil; +using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Items.Accessories +{ + [AutoloadEquip(EquipType.Balloon)] + [LegacyName("SamuraiBadge")] + [LegacyName("WarbanneroftheSun")] + public class WarbanneroftheRighteous : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + internal const float MaxBonus = 0.8f; + internal const float MaxDistance = 350f; + + public override void SetStaticDefaults() + { + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 5)); + ItemID.Sets.AnimatesAsSoul[Type] = true; + } + + public override void SetDefaults() + { + Item.width = 32; + Item.height = 78; + Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; + Item.rare = ItemRarityID.Purple; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.WarbanneroftheRighteous = true; + + modPlayer.warbannerGlow = !hideVisual; + + if (player.ownedProjectileCounts[ProjectileType()] < 1 && !hideVisual && !player.dead) + { + Projectile light = Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.Center, Vector2.Zero, ProjectileType(), 0, 0f, player.whoAmI); + } + + int maxValue = (int)(MaxBonus * 100); + float bonus = CalculateBonus(player) - 0.6f; + float displayBonus = (int)((bonus + 0.6f) * 100); // Should range from 0 to the maxValue + + if (player.Calamity().cooldowns.TryGetValue(WarbanneroftheRighteousBuff.ID, out var cooldown)) + { + cooldown.timeLeft = maxValue - (int)displayBonus; + } + else + { + player.AddCooldown(WarbanneroftheRighteousBuff.ID, maxValue); + } + + player.GetAttackSpeed() += 0.15f; + + // If damage is positive, boost melee damage, but negative damage is universal + if (bonus > 0) + player.GetDamage() += bonus; + else + player.GetDamage() += bonus; + + int targetCount = 0; + foreach (NPC npc in Main.ActiveNPCs) // More targets gradually reduces the burn damage for ALL targets + { + if (npc.Calamity().warbannerBurnMarked) + targetCount++; + } + for (int index = 0; index < Main.npc.Length; index++) + { + NPC nPC = Main.npc[index]; + float generousHitboxWidth = Math.Max(nPC.Hitbox.Width / 2f, nPC.Hitbox.Height / 2f) + (100 + 80 * Utils.GetLerpValue(0, 200, Math.Max(nPC.Hitbox.Width / 2f, nPC.Hitbox.Height / 2f))); // Adds some room so max bonus isnt when you're ON the hitbox + float intensity = Utils.Remap(Utils.Distance(player.Center, nPC.Center), MaxDistance + generousHitboxWidth, generousHitboxWidth, 1, 3, true); // We have to have this seperate from bonus, otherwise all effected enemies take damage based on the closest enemy + + if (Utils.Distance(nPC.Center, player.Center) < MaxDistance + generousHitboxWidth && (nPC.IsAnEnemy(true, true, false) || nPC.type == ModContent.NPCType()) && nPC.CanBeChasedBy()) + { + float minDamageMult = 0.35f; + int maxTargets = 25; + float damageMult = Utils.Remap(targetCount, maxTargets, 1, minDamageMult, 1); + + // Handles giving the Warbanner Burn effect + CalamityGlobalNPC modNPC = nPC.Calamity(); + if (!modNPC.warbannerBurnMarked) + { + modNPC.warbannerBurnDirection = Utils.DirectionTo(player.Center, nPC.Center); + modNPC.warbannerBurnMarked = true; + modNPC.warbannerBurnTimer = 2; + } + if (modNPC.warbannerBurnMarked) + { + modNPC.warbannerBurnIntensity = intensity; + modNPC.warbannerBurnDirection = Utils.DirectionTo(player.Center, nPC.Center); + int burnDamage = (int)player.GetBestClassDamage().ApplyTo(50 * damageMult); // There is up to a 3x multiplier on this damage depending on distance from the enemy + modNPC.warbannerBurnDamage = burnDamage; + modNPC.warbannerBurnStacks++; + modNPC.warbannerBurnTimer++; + modNPC.warbannerBurnHideEffects = hideVisual; + } + } + } + } + + private static float CalculateBonus(Player player) + { + float bonus = 0f; + + NPC closestTarget = player.Center.ClosestNPCAt(MaxDistance * 7); // extra range is to account for bonus range from massive targets + if (closestTarget != null) + { + float generousHitboxWidth = Math.Max(closestTarget.Hitbox.Width / 2f, closestTarget.Hitbox.Height / 2f) + (100 + 80 * Utils.GetLerpValue(0, 200, Math.Max(closestTarget.Hitbox.Width / 2f, closestTarget.Hitbox.Height / 2f))); // Adds some room so max bonus isnt when you're ON the hitbox + bonus = Utils.Remap(Utils.Distance(player.Center, closestTarget.Center), MaxDistance + generousHitboxWidth, generousHitboxWidth, 0, MaxBonus, true); + } + else + bonus = 0; + + return bonus; + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + CalamityUtils.DrawInventoryCustomScale( + spriteBatch, + texture: TextureAssets.Item[Type].Value, + position, + frame, + drawColor, + itemColor, + origin, + scale, + wantedScale: 0.6f, + drawOffset: new(0f, -2f) + ); + return false; + } + } +} diff --git a/Items/Accessories/WarbanneroftheSun.png b/Items/Accessories/WarbanneroftheRighteous.png similarity index 100% rename from Items/Accessories/WarbanneroftheSun.png rename to Items/Accessories/WarbanneroftheRighteous.png diff --git a/Items/Accessories/WarbanneroftheSun_Balloon.png b/Items/Accessories/WarbanneroftheRighteous_Balloon.png similarity index 100% rename from Items/Accessories/WarbanneroftheSun_Balloon.png rename to Items/Accessories/WarbanneroftheRighteous_Balloon.png diff --git a/Items/Accessories/WarbanneroftheSun.cs b/Items/Accessories/WarbanneroftheSun.cs deleted file mode 100644 index 86f81f490a..0000000000 --- a/Items/Accessories/WarbanneroftheSun.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using CalamityMod.CalPlayer; -using CalamityMod.Cooldowns; -using CalamityMod.NPCs.NormalNPCs; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - [AutoloadEquip(EquipType.Balloon)] - [LegacyName("SamuraiBadge")] - public class WarbanneroftheSun : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - internal const float MaxBonus = 0.4f; - internal const float MaxDistance = 500f; - - public override void SetStaticDefaults() - { - Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 5)); - ItemID.Sets.AnimatesAsSoul[Type] = true; - } - - public override void SetDefaults() - { - Item.width = 32; - Item.height = 78; - Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; - Item.rare = ItemRarityID.Purple; - Item.accessory = true; - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.warbannerOfTheSun = true; - - int maxValue = (int)(MaxBonus * 100); - float bonus = CalculateBonus(player) - 0.2f; - float displayBonus = (int)((bonus + 0.2f) * 100); // Should range from 0 to the maxValue - - if (player.Calamity().cooldowns.TryGetValue(WarbanneroftheSunBuff.ID, out var cooldown)) - { - cooldown.timeLeft = maxValue - (int)displayBonus; - } - else - { - player.AddCooldown(WarbanneroftheSunBuff.ID, maxValue); - } - - player.GetAttackSpeed() += 0.15f; - player.GetDamage() += bonus; - } - - private static float CalculateBonus(Player player) - { - float bonus = 0f; - - int closestNPC = -1; - foreach (NPC nPC in Main.ActiveNPCs) - { - if ((nPC.IsAnEnemy() || nPC.type == ModContent.NPCType()) && !nPC.dontTakeDamage) - { - closestNPC = nPC.whoAmI; - break; - } - } - float distance = -1f; - foreach (NPC nPC in Main.ActiveNPCs) - { - if (nPC.IsAnEnemy() && !nPC.dontTakeDamage) - { - float distance2 = Math.Abs(nPC.position.X + (float)(nPC.width / 2) - (player.position.X + (float)(player.width / 2))) + Math.Abs(nPC.position.Y + (float)(nPC.height / 2) - (player.position.Y + (float)(player.height / 2))); - if (distance == -1f || distance2 < distance) - { - distance = distance2; - closestNPC = nPC.whoAmI; - } - } - } - - if (closestNPC != -1) - { - NPC actualClosestNPC = Main.npc[closestNPC]; - - float generousHitboxWidth = Math.Max(actualClosestNPC.Hitbox.Width / 2f, actualClosestNPC.Hitbox.Height / 2f) + 80; // Adds some room so max bonus isnt when you're ON the hitbox - float hitboxEdgeDist = actualClosestNPC.Distance(player.Center) - generousHitboxWidth; - - if (hitboxEdgeDist < 0) - hitboxEdgeDist = 0; - - if (hitboxEdgeDist < MaxDistance) - { - bonus = MathHelper.Lerp(0f, MaxBonus, 1f - (hitboxEdgeDist / MaxDistance)); - - if (bonus > MaxBonus) - bonus = MaxBonus; - } - } - - return bonus; - } - - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) - { - CalamityUtils.DrawInventoryCustomScale( - spriteBatch, - texture: TextureAssets.Item[Type].Value, - position, - frame, - drawColor, - itemColor, - origin, - scale, - wantedScale: 0.6f, - drawOffset: new(0f, -2f) - ); - return false; - } - } -} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 6312122e3e..b781a8b41a 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -1966,12 +1966,14 @@ VoltaicJelly: { ''' } -WarbanneroftheSun: { - DisplayName: Warbanner of the Sun +WarbanneroftheRighteous: { + DisplayName: Warbanner of the Righteous Tooltip: ''' - Increases melee damage, true melee damage and melee speed the closer you are to enemies - These stat boosts max out at 20% + 15% increased melee speed + Melee damage increased by 20% when close to enemies, but all damage is decreased by 60% when far away + Emit a blazing aura that burns and repels nearby enemies + Enemies take increased damage the closer they are to you and the longer they are in the aura ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index 769687f230..969f12f917 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -128,6 +128,8 @@ TitanHeartBoom.DisplayName: Titan Heart Boom UrsaSlash.DisplayName: Ursa Slash VerstaltiteBobber.DisplayName: Verstaltite Bobber VoidFieldGenerator.DisplayName: Void Field Generator +WarbannerDamage.DisplayName: The Unmatched Power of the Sun +WarbannerLight.DisplayName: Warbanner Light WaterConvertor.DisplayName: Water Convertor WhiteLabSeeker.DisplayName: Seeking Mechanism WulfrumBobber.DisplayName: Wulfrum Bobber diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index d88cf3f558..bf2b16ad40 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -125,7 +125,7 @@ Cooldowns: { TarragonCloak: Tarragon Cloak Cooldown TarragonImmunity: Tarragon Immunity Cooldown UniverseSplitter: Universe Splitter Cooldown - WarbanneroftheSunBuff: Warbanner Strength + WarbanneroftheRighteousBuff: Warbanner Strength WulfrumBastionActive: Power Armor Durability WulfrumBastionCooldown: Wulfrum Bastion Cooldown WulfrumRoverDriveDurability: Protective Matrix Durability diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 90b7838760..966906302d 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -89,6 +89,7 @@ using CalamityMod.NPCs.SunkenSea; using CalamityMod.Packets; using CalamityMod.ExtraTextures; using MonoMod.Utils; +using CalamityMod.Dusts; namespace CalamityMod.NPCs { @@ -284,6 +285,14 @@ namespace CalamityMod.NPCs public int aCrunch = 0; public int crumble = 0; + public int warbannerBurnTime = 0; // Determines the rate that the enemy is damaged + public int warbannerBurnTimer = 0; // The duration of the debuff + public int warbannerBurnStacks = 0; // The stacks increase how fast the debuff hits + public int warbannerBurnDamage = 0; // Damage of the hits based on player's damage + public Vector2 warbannerBurnDirection; + public float warbannerBurnIntensity = 0; + public bool warbannerBurnMarked = false; + public bool warbannerBurnHideEffects = false; public const int veriumDoomTime = 90; public int veriumDoomTimer = 0; public int veriumDoomStacks = 0; @@ -519,6 +528,14 @@ namespace CalamityMod.NPCs myClone.aCrunch = aCrunch; myClone.crumble = crumble; + myClone.warbannerBurnTime = warbannerBurnTime; + myClone.warbannerBurnTimer = warbannerBurnTimer; + myClone.warbannerBurnStacks = warbannerBurnStacks; + myClone.warbannerBurnDamage = warbannerBurnDamage; + myClone.warbannerBurnDirection = warbannerBurnDirection; + myClone.warbannerBurnIntensity = warbannerBurnIntensity; + myClone.warbannerBurnMarked = warbannerBurnMarked; + myClone.warbannerBurnHideEffects = warbannerBurnHideEffects; myClone.veriumDoomTimer = veriumDoomTimer; myClone.veriumDoomStacks = veriumDoomStacks; myClone.veriumDoomMarked = veriumDoomMarked; @@ -5591,6 +5608,75 @@ namespace CalamityMod.NPCs if (cursorFocus > 0 && cursorFocus < cursorFocusMax) cursorFocus--; + + if (warbannerBurnTimer > 0) + warbannerBurnTimer--; + if (warbannerBurnTimer == 0 && warbannerBurnMarked) + { + warbannerBurnTime = 0; + warbannerBurnDamage = 0; + warbannerBurnMarked = false; + warbannerBurnStacks = 0; + } + if (warbannerBurnMarked) + { + int maxStacks = 300; // Time in frames needed to reach max power + int fastestBurnRate = 2; + int slowestBurnRate = 20; + float burnPower = Utils.Remap(warbannerBurnStacks, 0, maxStacks, slowestBurnRate, fastestBurnRate, true); + + float sizeBonus = (1 + Utils.GetLerpValue(0, 170, Math.Max(npc.Hitbox.Width / 2f, npc.Hitbox.Height / 2f))); + + if (!warbannerBurnHideEffects) + { + Lighting.AddLight(npc.Center, Color.Gold.ToVector3() * 0.3f * warbannerBurnIntensity); + } + if (warbannerBurnStacks == maxStacks && !warbannerBurnHideEffects) + { + // Sound and visual for hitting max stacks + for (int i = 0; i < 15; i++) + { + Particle spark = new SparkParticle(npc.Center, new Vector2(13, 13).RotatedByRandom(100) * Main.rand.NextFloat(0.4f, 1f), true, 45, 0.85f, Main.rand.NextBool() ? Color.Goldenrod : Color.Orange); + GeneralParticleHandler.SpawnParticle(spark); + } + SoundStyle fullPower = new("CalamityMod/Sounds/Custom/Providence/ProvidenceBurn"); + SoundEngine.PlaySound(fullPower with { Volume = 0.7f, Pitch = 0.7f }, npc.Center); + warbannerBurnStacks++; + } + if (warbannerBurnIntensity > 2 && npc.CanBeMoved(true)) + { + npc.velocity *= 0.99f - 0.25f * Utils.GetLerpValue(2, 3, warbannerBurnIntensity); + if (npc.velocity.Length() > 5) // Repel leaping enemies + npc.velocity = -npc.velocity * 0.7f; + } + if (warbannerBurnTime == 0) + { + if (!warbannerBurnHideEffects) + { + int particleLevel = (int)(MathHelper.Clamp((slowestBurnRate - burnPower) * 0.15f, 1, 2) * warbannerBurnIntensity); + for (int d = 0; d < particleLevel; d++) + { + Color color = Main.rand.NextBool() ? Color.Goldenrod : Color.Lerp(Color.OrangeRed, Color.Orange, Main.rand.NextFloat(0, 1)); ; + Vector2 sparkPos = npc.Center - warbannerBurnDirection * 220 * Utils.GetLerpValue(0, 200, Math.Max(npc.Hitbox.Width / 2f, npc.Hitbox.Height / 2f)); + float velAdjust = Main.rand.NextFloat(2, 7) * warbannerBurnIntensity * sizeBonus; + Vector2 endVel = warbannerBurnDirection * velAdjust; + Vector2 startVel = (warbannerBurnDirection * velAdjust).RotatedByRandom(0.6f * warbannerBurnIntensity); + Particle sparks = new VelChangingSpark(sparkPos, startVel, endVel, "CalamityMod/Particles/SmallBloom", Main.rand.Next(18, 22 + 1), Main.rand.NextFloat(0.1f, 0.25f) * sizeBonus, color * 0.75f, new Vector2(0.7f, 1), true, false, 0, false, 0.45f, 0.1f); + GeneralParticleHandler.SpawnParticle(sparks); + Dust lust2 = Dust.NewDustPerfect(sparkPos, ModContent.DustType(), startVel, Scale: Main.rand.NextFloat(0.7f, 1.1f) * sizeBonus); + lust2.noGravity = true; + lust2.color = color; + lust2.noLightEmittence = true; + } + } + var player = Main.LocalPlayer; + Projectile burnHit = Projectile.NewProjectileDirect(player.GetSource_FromThis(), npc.Center, Vector2.Zero, ProjectileType(), (int)(warbannerBurnDamage * warbannerBurnIntensity), 0, Main.myPlayer, npc.whoAmI); + burnHit.ArmorPenetration = 50; + warbannerBurnTime = (int)(burnPower + (3 - warbannerBurnIntensity) * 4); + } + warbannerBurnTime--; + } + if (veriumDoomTimer > 0) veriumDoomTimer--; if (veriumDoomTimer == 0 && veriumDoomMarked) @@ -6391,7 +6477,7 @@ namespace CalamityMod.NPCs public override void HitEffect(NPC npc, NPC.HitInfo hit) { if (npc.life <= 0 && npc.Organic() && ashesOnDeath > 0) - DeathAshParticle.CreateAshesFromNPC(npc); + DeathAshParticle.CreateAshesFromNPC(npc, Vector2.Zero); // Cultist shield flicker if (npc.type == NPCID.CultistBoss) diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index 4a1010d253..8f6db58b0b 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -1225,7 +1225,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { npcLoot.Add(ModContent.ItemType(), 4); npcLoot.Add(ModContent.ItemType(), 7); - npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 10); npcLoot.Add(ModContent.ItemType(), 10); npcLoot.Add(ModContent.ItemType()); npcLoot.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 1, 10, 15, 15, 20)); diff --git a/NPCs/SupremeCalamitas/SupremeCataclysm.cs b/NPCs/SupremeCalamitas/SupremeCataclysm.cs index bf96e5dac6..f20fb06bb9 100644 --- a/NPCs/SupremeCalamitas/SupremeCataclysm.cs +++ b/NPCs/SupremeCalamitas/SupremeCataclysm.cs @@ -576,7 +576,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - DeathAshParticle.CreateAshesFromNPC(NPC); + DeathAshParticle.CreateAshesFromNPC(NPC, Vector2.Zero); } } } diff --git a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs index 34f058b979..596c9706a8 100644 --- a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs +++ b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs @@ -612,7 +612,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - DeathAshParticle.CreateAshesFromNPC(NPC); + DeathAshParticle.CreateAshesFromNPC(NPC, Vector2.Zero); } } } diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index b23d3bc8cd..2e8e90e8d9 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -3266,7 +3266,7 @@ namespace CalamityMod.NPCs.Yharon // Turn into dust on death. if (NPC.life <= 0) - DeathAshParticle.CreateAshesFromNPC(NPC); + DeathAshParticle.CreateAshesFromNPC(NPC, Vector2.Zero); } } #endregion diff --git a/Particles/DeathAshParticle.cs b/Particles/DeathAshParticle.cs index 9687520e99..eae6742705 100644 --- a/Particles/DeathAshParticle.cs +++ b/Particles/DeathAshParticle.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Particles public Color AshColor; public Vector2 Center; public Vector2 Velocity; + public static Vector2 VelOverride; public Vector2 TopLeft => Center - Vector2.One * Scale * 3.5f; public Vector2 TopRight => Center + new Vector2(1f, -1f) * Scale * 3.5f; public Vector2 BottomRight => Center + Vector2.One * Scale * 3.5f; @@ -84,12 +85,13 @@ namespace CalamityMod.Particles Main.instance.GraphicsDevice.SetRenderTarget(null); } - public static void CreateAshesFromNPC(NPC npc) + public static void CreateAshesFromNPC(NPC npc, Vector2 velocityOverride) { // Don't create ashes serverside. if (Main.netMode == NetmodeID.Server) return; + VelOverride = velocityOverride; PendingNPCsToDraw[npc] = new(true, ManagedRenderTarget.CreateScreenSizedTarget); } @@ -228,11 +230,19 @@ namespace CalamityMod.Particles float brightness = (AshColor.R + AshColor.G + AshColor.B) / 765f; Time++; + Scale = MathHelper.Clamp(Scale - (brightness < 0.1f ? 0.08f : 0.008f), 0f, 1f); + float dissipationFactor = Utils.GetLerpValue(6f, 16f, Velocity.Length(), true); float velocityInterpolant = Utils.GetLerpValue(25f - dissipationFactor * 10f, 80f - dissipationFactor * 45f, Time, true); Vector2 idealVelocity = new Vector2(Main.windSpeedCurrent * MathHelper.Lerp(0.8f, 1.2f, (float)Math.Sin(Center.Y / 50f + ID)) * 20f, (float)Math.Sin(Main.time / 20f + ID * 0.01f) * 3f - 1f); + if (VelOverride != Vector2.Zero) + { + Vector2 useVel = VelOverride.RotateRandom(0.01f * ID); + idealVelocity = new Vector2(useVel.X * MathHelper.Lerp(0.8f, 1.2f, (float)Math.Sin(Main.time / 20f + ID)), useVel.Y * MathHelper.Lerp(0.8f, 1.2f, (float)Math.Sin(Main.time / 20f + ID))); + } + Velocity = Vector2.Lerp(Velocity, idealVelocity, velocityInterpolant * 0.16f); Center += Velocity; } diff --git a/Particles/VelChangingSpark .cs b/Particles/VelChangingSpark .cs index 6af1457062..f917530522 100644 --- a/Particles/VelChangingSpark .cs +++ b/Particles/VelChangingSpark .cs @@ -53,7 +53,10 @@ namespace CalamityMod.Particles { if (!FadeIn) { - Scale *= 0.95f; + if ((float)Time / (float)Lifetime < 0.5f) + { + Scale *= 0.95f; + } Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); } else @@ -67,7 +70,11 @@ namespace CalamityMod.Particles Scale = MathHelper.Lerp(Scale, FadeInScale, -0.21f); } } - Velocity *= 0.95f; + if ((float)Time / (float)Lifetime < 0.8f) + { + Velocity *= 0.95f; + EndVelocity *= 0.95f; + } Velocity = new Vector2(MathHelper.Lerp(Velocity.X, EndVelocity.X, LerpRate), MathHelper.Lerp(Velocity.Y, EndVelocity.Y, LerpRate)); diff --git a/Projectiles/Melee/HolyColliderHolyFire.cs b/Projectiles/Melee/HolyColliderHolyFire.cs index 307b017ceb..30b92448a8 100644 --- a/Projectiles/Melee/HolyColliderHolyFire.cs +++ b/Projectiles/Melee/HolyColliderHolyFire.cs @@ -171,7 +171,8 @@ namespace CalamityMod.Projectiles.Melee Particle spark = new SparkParticle(Projectile.Center, new Vector2(21, 21).RotatedByRandom(100) * Main.rand.NextFloat(0.4f, 1f), true, 55, 0.85f, Main.rand.NextBool() ? Color.Goldenrod : Color.OrangeRed); GeneralParticleHandler.SpawnParticle(spark); } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.35), Projectile.knockBack, Projectile.owner, 1.8f); + + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.47), Projectile.knockBack, Projectile.owner, 1.8f); } } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Typeless/WarbannerDamage.cs b/Projectiles/Typeless/WarbannerDamage.cs new file mode 100644 index 0000000000..892d1b9eaf --- /dev/null +++ b/Projectiles/Typeless/WarbannerDamage.cs @@ -0,0 +1,39 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class WarbannerDamage : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = 2; + Projectile.height = 2; + Projectile.friendly = true; + Projectile.penetrate = 1; + Projectile.extraUpdates = 0; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.timeLeft = 2; + } + + // If the AI parameter isn't a valid NPC slot, it can hit anything. Otherwise it can only hit one NPC. + public override bool? CanHitNPC(NPC target) + { + if (Projectile.ai[0] < 0f || Projectile.ai[0] > 199f || Projectile.ai[0] == target.whoAmI) + return null; + return (bool?)false; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 30); + } + + } +} diff --git a/Projectiles/Typeless/WarbannerLight.cs b/Projectiles/Typeless/WarbannerLight.cs new file mode 100644 index 0000000000..214c03b6cf --- /dev/null +++ b/Projectiles/Typeless/WarbannerLight.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class WarbannerLight : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer moddedOwner => Owner.Calamity(); + public Color bColor = Color.White; + public int time = 0; + public float rotMult = 0.05f; + public int direction = 1; + public float rot2 = 0; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 1; + Projectile.ignoreWater = true; + Projectile.timeLeft = 300; + Projectile.tileCollide = false; + Projectile.friendly = true; + Projectile.penetrate = -1; + } + + public override void AI() + { + float rate = Main.GlobalTimeWrappedHourly * 5; + List eColors = new List() + { + Color.Goldenrod, + Color.Orange + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + bColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + Projectile.Center = Owner.MountedCenter; + + if (moddedOwner.warbannerGlow && moddedOwner.WarbanneroftheRighteous) + Projectile.timeLeft++; + else + Projectile.Kill(); + if (Owner.dead) + Projectile.Kill(); + + // Emit some light + Lighting.AddLight(Projectile.Center, Color.Goldenrod.ToVector3() * 1.5f); + + rot2 = Math.Abs((float)Math.Sin(time * 0.15f / MathHelper.Pi) * 0.2f) + 0.8f; + + if (time % 2 == 0) + { + Vector2 dustVel = new Vector2(10, 10).RotatedByRandom(100); + Dust dust = Dust.NewDustPerfect(Owner.Center + dustVel, ModContent.DustType(), dustVel * Main.rand.NextFloat(0.1f, 0.4f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.5f, 0.7f); + dust.color = bColor; + dust.noLightEmittence = true; + } + + time++; + } + public override bool PreDraw(ref Color lightColor) + { + Texture2D rTexture = ModContent.Request("CalamityMod/Particles/ShatteredExplosion").Value; + Texture2D bTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Color drawColor = bColor; + + for (int i = 0; i < 5; i++) + { + float bScale2 = 0.75f; + Main.EntitySpriteDraw(bTexture, Owner.Center - Main.screenPosition, null, Color.Lerp(drawColor, Color.White, i * 0.15f) with { A = 0 }, 0, bTexture.Size() * 0.5f, (bScale2 - i * 0.15f) * rot2, SpriteEffects.None, 0); + } + + Main.EntitySpriteDraw(rTexture, Owner.Center - Main.screenPosition, null, drawColor with { A = 0 }, Main.rand.NextFloat(-2, 2), rTexture.Size() * 0.5f, 0.03f * rot2, SpriteEffects.None, 0); + Main.EntitySpriteDraw(rTexture, Owner.Center - Main.screenPosition, null, drawColor with { A = 0 }, Main.rand.NextFloat(-2, 2), rTexture.Size() * 0.5f, 0.04f * rot2, SpriteEffects.None, 0); + return false; + } + public override bool? CanDamage() => false; + } +}