From e84929ca950078f0142ea8c148d3dba94792c72d Mon Sep 17 00:00:00 2001 From: IbanPlay <56191483+IbanPlay@users.noreply.github.com> Date: Thu, 17 Feb 2022 22:34:39 +0100 Subject: [PATCH] Brimflame frenzy --- Buffs/Cooldowns/BrimflameFrenzyCooldown.cs | 24 ---------- Buffs/Cooldowns/BrimflameFrenzyCooldown.png | Bin 640 -> 0 bytes CalPlayer/CalamityPlayer.cs | 7 +-- CalPlayer/CalamityPlayerMiscEffects.cs | 5 +- Items/Armor/BrimflameScowl.cs | 8 +--- .../BrimflameFrenzyCooldown.cs | 45 ++++++++++++++++++ UI/CooldownIndicators/CooldownIndicator.cs | 41 +++++++++++++++- 7 files changed, 88 insertions(+), 42 deletions(-) delete mode 100644 Buffs/Cooldowns/BrimflameFrenzyCooldown.cs delete mode 100644 Buffs/Cooldowns/BrimflameFrenzyCooldown.png create mode 100644 UI/CooldownIndicators/BrimflameFrenzyCooldown.cs diff --git a/Buffs/Cooldowns/BrimflameFrenzyCooldown.cs b/Buffs/Cooldowns/BrimflameFrenzyCooldown.cs deleted file mode 100644 index 824561c866..0000000000 --- a/Buffs/Cooldowns/BrimflameFrenzyCooldown.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.Cooldowns -{ - public class BrimflameFrenzyCooldown : ModBuff - { - public override void SetDefaults() - { - DisplayName.SetDefault("Brimflame Frenzy Cooldown"); - Description.SetDefault("Your use of brimstone magic has left you exhausted"); - Main.debuff[Type] = true; - Main.pvpBuff[Type] = true; - Main.buffNoSave[Type] = true; - longerExpertDebuff = false; - canBeCleared = false; - } - - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().brimflameFrenzyCooldown = true; - } - } -} diff --git a/Buffs/Cooldowns/BrimflameFrenzyCooldown.png b/Buffs/Cooldowns/BrimflameFrenzyCooldown.png deleted file mode 100644 index 4f23a5fae59b5741be4aaa8c98057f9098628681..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 640 zcmV-`0)PF9P)Px%I!Q!9R9J=Om(5F5Q5eR56UkT*2$ncyb;BZN5ebGch%E}nO>S~kP*m$cTjVA} zA|kLw{RLCFaplTYg)NL2a8*%EU(y6)BW5HBjUi-1dGGnS_j%5H z-g9p%O1A<~{_%C4O(aUUrU15V=1qO1fOUY2Z8-o=?b`vs+|nWdojcnA=-IOkfQ}Of ztqJbjowoW3jdv-1H}l+IECK;IuvLGg+(k;}mQ36^UjyLuxg!9aIl3Q!i5H(td+bD# zBiZdW>v}j22tDc5D<=V1%Vn(gref8KUFH8uI1Wg;*3?xlDo;KDFgsuKw!0+l1`&<} zf8+A)cK}?E-Py zhu$na2Lf>5k6j?eF7H2@>&N39$h7+>tbASrpt?}D#<@8m!f_yJtuyVBcc80KX#9oq zht0e cooldown.GetType() == typeof(BrimflameFrenzyCooldown))) { if (player.whoAmI == Main.myPlayer) { diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 4c4dfde575..e9ad18603e 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -1047,8 +1047,6 @@ namespace CalamityMod.CalPlayer dogTextCooldown--; if (titanCooldown > 0) titanCooldown--; - if (brimflameFrenzyTimer > 0) - brimflameFrenzyTimer--; if (fungalSymbioteTimer > 0) fungalSymbioteTimer--; if (aBulwarkRareTimer > 0) @@ -1602,8 +1600,7 @@ namespace CalamityMod.CalPlayer { brimflameFrenzy = false; player.ClearBuff(ModContent.BuffType()); - player.AddBuff(ModContent.BuffType(), BrimflameScowl.CooldownLength, true); - brimflameFrenzyTimer = BrimflameScowl.CooldownLength; + Cooldowns.Add(new BrimflameFrenzyCooldown(BrimflameScowl.CooldownLength, player)); } if (!bloodflareMelee && bloodflareFrenzy) { diff --git a/Items/Armor/BrimflameScowl.cs b/Items/Armor/BrimflameScowl.cs index a8a2dd50eb..d4608e902d 100644 --- a/Items/Armor/BrimflameScowl.cs +++ b/Items/Armor/BrimflameScowl.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.Cooldowns; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.UI.CooldownIndicators; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -44,14 +45,9 @@ namespace CalamityMod.Items.Armor if (!modPlayer.brimflameFrenzy) { frenzy = false; - player.AddBuff(ModContent.BuffType(), CooldownLength, true); - modPlayer.brimflameFrenzyTimer = CooldownLength; + modPlayer.Cooldowns.Add(new BrimflameFrenzyCooldown(CooldownLength, player)); } } - if (modPlayer.brimflameFrenzyTimer == 1) //sound when ready to use again - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/BrimflameRecharge"), player.Center); - } } public override void UpdateEquip(Player player) diff --git a/UI/CooldownIndicators/BrimflameFrenzyCooldown.cs b/UI/CooldownIndicators/BrimflameFrenzyCooldown.cs new file mode 100644 index 0000000000..6c7e4b9c25 --- /dev/null +++ b/UI/CooldownIndicators/BrimflameFrenzyCooldown.cs @@ -0,0 +1,45 @@ +using CalamityMod.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.Audio; +using Terraria.Graphics.Shaders; +using static Terraria.ModLoader.ModContent; +using static CalamityMod.CalamityUtils; +using CalamityMod.CalPlayer; +using Terraria.ModLoader; + +namespace CalamityMod.UI.CooldownIndicators +{ + public class BrimflameFrenzyCooldown : CooldownIndicator + { + public override string SyncID => "BrimflameFrenzy"; + public override bool DisplayMe => true; + public override string Name => "Brimflame Frenzy Cooldown"; + public override string Texture => "CalamityMod/UI/CooldownIndicators/BrimflameFrenzy"; + public override Color OutlineColor => new Color(211, 124, 93); + public override Color CooldownColorStart => Color.Lerp(new Color(107, 6, 6), new Color(228, 78, 78), 1 - Completion); + public override Color CooldownColorEnd => Color.Lerp(new Color(107, 6, 6), new Color(228, 78, 78), 1 - Completion); + + public override LegacySoundStyle EndSound => AfflictedPlayer.Calamity().mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/Custom/BrimflameRecharge"); + + public BrimflameFrenzyCooldown(int duration, Player player) : base(duration, player) + { + } + + public override bool UseCustomDraw => true; + + //Add red eyes to the icon + public override void CustomDraw(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.CustomDraw(spriteBatch, position, opacity, scale); + + Texture2D sprite = GetTexture(Texture + "Eyes"); + //Draw the icon + spriteBatch.Draw(sprite, position, null, Color.Crimson * opacity * (1 - Completion), 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + } + } +} \ No newline at end of file diff --git a/UI/CooldownIndicators/CooldownIndicator.cs b/UI/CooldownIndicators/CooldownIndicator.cs index ff6193531a..a3a14f13a2 100644 --- a/UI/CooldownIndicators/CooldownIndicator.cs +++ b/UI/CooldownIndicators/CooldownIndicator.cs @@ -93,7 +93,28 @@ namespace CalamityMod.UI.CooldownIndicators /// /// Use this method if you want to handle the drawing yourself. Only called if UseCustomDraw is set to true. /// - public virtual void CustomDraw(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) { } + public virtual void CustomDraw(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + Texture2D sprite = ModContent.GetTexture(Texture); + Texture2D outline = ModContent.GetTexture(TextureOutline); + Texture2D barBase = ModContent.GetTexture(ChargeBarTexture); + + //Draw the ring + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix); + ApplyBarShaders(opacity); + + spriteBatch.Draw(barBase, position, null, Color.White * opacity, 0, barBase.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix); + + //Draw the outline + spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + //Draw the icon + spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + } /// /// Set this to true to disable default drawing, thus calling CustomDraw()/CustomDrawCompact() instead. This only applies to the compact mode of display @@ -102,7 +123,23 @@ namespace CalamityMod.UI.CooldownIndicators /// /// Use this method if you want to handle the drawing yourself. Only called if UseCustomDrawCompact is set to true. /// - public virtual void CustomDrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) { } + public virtual void CustomDrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + Texture2D sprite = ModContent.GetTexture(Texture); + Texture2D outline = ModContent.GetTexture(TextureOutline); + Texture2D overlay = ModContent.GetTexture(TextureOverlay); + + //Draw the outline + spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + //Draw the icon + spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + //Draw the small overlay + int lostHeight = (int)Math.Ceiling(overlay.Height * (1 - Completion)); + Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight); + spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, OutlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + } /// /// The texture of the charge bar. If set to a different texture path than the bar base, and if UseCustomDraw is set to false , it will be used as the ring around the cooldown icon