From d07c7993fddca7e0837a784b87be8f7513d3f07b Mon Sep 17 00:00:00 2001 From: mochi-angel Date: Sat, 26 Apr 2025 15:26:20 -0700 Subject: [PATCH] Flesh Totem Start --- Buffs/Summon/FleshTotemBuff.cs | 17 +++ Buffs/Summon/FleshTotemBuff.png | Bin 0 -> 528 bytes CalPlayer/CalamityPlayer.cs | 14 +++ CalPlayer/CalamityPlayerHitHurt.cs | 27 +++-- .../{FleshTotem.cs => FleshTotemStorage.cs} | 11 +- Items/Accessories/FleshTotem.cs | 29 ++++- .../en-US/Mods.CalamityMod.Buffs.hjson | 5 + .../Mods.CalamityMod.Items.Accessories.hjson | 8 +- .../Mods.CalamityMod.Projectiles.Magic.hjson | 1 + Projectiles/Magic/FleshTotemMinion.cs | 104 ++++++++++++++++++ Projectiles/Magic/VoidVortexProj.cs | 1 - 11 files changed, 202 insertions(+), 15 deletions(-) create mode 100644 Buffs/Summon/FleshTotemBuff.cs create mode 100644 Buffs/Summon/FleshTotemBuff.png rename Cooldowns/{FleshTotem.cs => FleshTotemStorage.cs} (57%) create mode 100644 Projectiles/Magic/FleshTotemMinion.cs diff --git a/Buffs/Summon/FleshTotemBuff.cs b/Buffs/Summon/FleshTotemBuff.cs new file mode 100644 index 0000000000..524cc6f2a1 --- /dev/null +++ b/Buffs/Summon/FleshTotemBuff.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Projectiles.Magic; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class FleshTotemBuff : BaseSummonBuff + { + protected override int MinionProjectileType => ModContent.ProjectileType(); + + protected override ref bool MinionBool => ref BuffModdedOwner.fleshTotem; + } +} diff --git a/Buffs/Summon/FleshTotemBuff.png b/Buffs/Summon/FleshTotemBuff.png new file mode 100644 index 0000000000000000000000000000000000000000..d99a0b8a1997505a85a348639385441d163053be GIT binary patch literal 528 zcmV+r0`L8aP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf6951U69E94oEQKA0i{VqK~z{r<(Ium z13?spcefD?DU{VhG)W_F6j5vh!7hqbULe?|@ELp(i*(`(Scqsk!BVu)2o{<|EOgN# zM6g+9&&&~Wm+=QAnZ>U;H=AX4?wPrFXWd|C*#U2_?<(jML&I(?9)1iEHz>@j%*P54 zlJx@}{SBS)T1T3vJBWP_c#*cmWxnQ+iyUB?1Ua?;0`1v5NFQp`++@sfNRG!CvxrcxmoD+NC+i2FFv%{ zx`KYU7p&O>2?u0-6X}rb52k97$miJWfUNW5bG*Eq_Ua0h{emEzo0 literal 0 HcmV?d00001 diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 35a842eb61..e97bb0adc3 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -852,6 +852,7 @@ namespace CalamityMod.CalPlayer public bool community = false; public bool shatteredCommunity = false; public bool fleshTotem = false; + public int fleshTotemManaStorage = 0; public bool bloodPact = false; public bool bloodPactBoost = false; public bool bloodflareCore = false; @@ -5599,6 +5600,19 @@ namespace CalamityMod.CalPlayer life.noGravity = true; } } + + if (modPlayer.fleshTotem) + { + if (Main.myPlayer == Player.whoAmI) + { + //Main.NewText(fleshTotemManaStorage); + fleshTotemManaStorage += manaConsumed; + if (fleshTotemManaStorage >= FleshTotem.manaStorageMax) + { + fleshTotemManaStorage = FleshTotem.manaStorageMax; + } + } + } } #endregion } diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 32dc6b33e5..15fd719931 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -14,6 +14,7 @@ using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Armor.Aerospec; +using CalamityMod.Items.Armor.Bloodflare; using CalamityMod.Items.Armor.Demonshade; using CalamityMod.Items.Armor.LunicCorps; using CalamityMod.Items.Armor.Silva; @@ -32,6 +33,7 @@ using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.Particles; +using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Typeless; @@ -794,10 +796,6 @@ namespace CalamityMod.CalPlayer // The amount of damage that will be dealt is yet to be determined. // - // Can't have any cooldowns here because dodges grrrrr.... - if (fleshTotem && !Player.HasCooldown(Cooldowns.FleshTotem.ID) && TotalEnergyShielding <= 0) - contactDamageReduction += 0.5; - if (tarragonCloak && tarraMelee && !Player.HasCooldown(Cooldowns.TarragonCloak.ID)) contactDamageReduction += Buffs.StatBuffs.TarragonCloak.ContactDamageReduction; @@ -1165,10 +1163,9 @@ namespace CalamityMod.CalPlayer if (!hasIFrames && !Player.creativeGodMode) nextHitDealsDefenseDamage |= npc.Calamity().canBreakPlayerDefense; - // ModifyHit (Flesh Totem effect happens here) -> Hurt (includes dodges) -> OnHit + // ModifyHit -> Hurt (includes dodges) -> OnHit // As such, to avoid cooldowns proccing from dodge hits, do it here - if (fleshTotem && !Player.HasCooldown(Cooldowns.FleshTotem.ID) && hurtInfo.Damage > 0) - Player.AddCooldown(Cooldowns.FleshTotem.ID, CalamityUtils.SecondsToFrames(20)); + if (NPC.AnyNPCs(ModContent.NPCType())) Player.AddBuff(ModContent.BuffType(), 15, true); @@ -2482,6 +2479,22 @@ namespace CalamityMod.CalPlayer } } + if (fleshTotem && hurtInfo.Damage > 0) + { + if (fleshTotemManaStorage >= 25) + SoundEngine.PlaySound(BloodflareHeadRanged.ActivationSound, Player.Center); + int lostSoulAmount = fleshTotemManaStorage / 25; + if (Player.ownedProjectileCounts[ModContent.ProjectileType()] != 0) + { + for (int k = 0; k < lostSoulAmount; k++) + { + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.4f, 0.55f), ModContent.ProjectileType(), FleshTotem.lostSoulDamage, 0f, Main.myPlayer, 0f, 0f, 3f); + } + } + + fleshTotemManaStorage = 0; + } + // By setting brainOfConfusionItem, these accessories have this code already, // but doing it again allows for increased duration + The Amalgam's other buffs, // and also doesn't have random chance (why does Brain of Confusion not guarantee confusion on hit) diff --git a/Cooldowns/FleshTotem.cs b/Cooldowns/FleshTotemStorage.cs similarity index 57% rename from Cooldowns/FleshTotem.cs rename to Cooldowns/FleshTotemStorage.cs index 8b1fe7812f..1f5140dfaa 100644 --- a/Cooldowns/FleshTotem.cs +++ b/Cooldowns/FleshTotemStorage.cs @@ -1,13 +1,16 @@ -using Microsoft.Xna.Framework; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Accessories; +using Microsoft.Xna.Framework; using Terraria.Localization; namespace CalamityMod.Cooldowns { - public class FleshTotem : CooldownHandler + public class FleshTotemStorage : CooldownHandler { - public static new string ID => "FleshTotem"; + public static new string ID => "FleshTotemStorage"; - public override bool ShouldDisplay => true; + private CalamityPlayer CalPlayer => instance.player.Calamity(); + public override bool ShouldDisplay => CalPlayer.fleshTotem; public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); public override string Texture => "CalamityMod/Cooldowns/FleshTotem"; public override Color OutlineColor => new Color(157, 248, 234); diff --git a/Items/Accessories/FleshTotem.cs b/Items/Accessories/FleshTotem.cs index 43a6d21ea8..a9fdee5bdd 100644 --- a/Items/Accessories/FleshTotem.cs +++ b/Items/Accessories/FleshTotem.cs @@ -1,4 +1,9 @@ -using CalamityMod.CalPlayer; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Cooldowns; +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,6 +13,10 @@ namespace CalamityMod.Items.Accessories public class FleshTotem : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public static int manaStorageMax = 600; + public const int lostSoulDamage = 200; + public override void SetDefaults() { Item.width = 26; @@ -21,6 +30,24 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.fleshTotem = true; + player.statManaMax2 += 30; + player.GetCritChance() += 5; + if (player.whoAmI == Main.myPlayer) + { + var source = player.GetSource_Accessory(Item); + if (player.FindBuffIndex(ModContent.BuffType()) == -1) + { + player.AddBuff(ModContent.BuffType(), 3600, true); + } + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + { + int damage = (int)player.GetTotalDamage().ApplyTo(lostSoulDamage); + + int effigy = Projectile.NewProjectile(source, player.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 2f, Main.myPlayer); + if (Main.projectile.IndexInRange(effigy)) + Main.projectile[effigy].originalDamage = lostSoulDamage; + } + } } } } diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index 8c05baf6a7..35b35901e1 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -1603,3 +1603,8 @@ PopoNoselessBuff: { DisplayName: Noseless Popo Description: Your nose has been stolen! } + +FleshTotemBuff: { + DisplayName: Flesh Totem Buff + Description: Mods.CalamityMod.Buffs.FleshTotemBuff.Description +} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index ce837a0f34..7bae0e6b06 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -770,8 +770,12 @@ FleshTotem: { DisplayName: Flesh Totem Tooltip: ''' - Halves enemy contact damage - When you take contact damage this effect has a 20 second cooldown + 5% increased magic critical strike chance + +30 max mana + Summons an effigy above your head that stores mana as you use it + The effigy occasionally pulses, restoring 30 mana + Pulses appear more frequently the more mana is stored + Upon being struck, the effigy unleashes all stored up mana as vengeful souls that chase your enemies ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson index 9e64da189d..1d4c3faa63 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson @@ -262,3 +262,4 @@ WyvernFeatherPurple.DisplayName: Feather WyvernProjectile.DisplayName: Wyvern YharimsCrystalBeam.DisplayName: Yharim's Beam YharimsCrystalPrism.DisplayName: Yermes Christal +FleshTotemMinion.DisplayName: Flesh Totem Minion diff --git a/Projectiles/Magic/FleshTotemMinion.cs b/Projectiles/Magic/FleshTotemMinion.cs new file mode 100644 index 0000000000..dca4e0dcb5 --- /dev/null +++ b/Projectiles/Magic/FleshTotemMinion.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.CalPlayer; +using CalamityMod.NPCs.BrimstoneElemental; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class FleshTotemMinion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Items/Accessories/FleshTotem"; + + public int pulseTimer = 0; + public override void SetDefaults() + { + Projectile.width = 30; + Projectile.height = 26; + Projectile.netImportant = true; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.timeLeft = 18000; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.timeLeft *= 5; + Projectile.DamageType = DamageClass.Magic; + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + if (!modPlayer.fleshTotem) + { + Projectile.active = false; + return; + } + if (player.dead) + { + modPlayer.fleshTotem = false; + } + if (modPlayer.fleshTotem) + { + Projectile.timeLeft = 2; + } + Lighting.AddLight(Projectile.Center, 0f, 0.25f, 1.5f); + Projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 85f); + if (player.gravDir == -1f) + { + Projectile.position.Y += 170f; + Projectile.rotation = MathHelper.Pi; + } + else + { + Projectile.rotation = 0f; + } + for (int i = 0; i < 2; i++) + { + int dustType = Main.rand.NextBool() ? 66 : 247; + float rotMulti = Main.rand.NextFloat(0.3f, 1f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Vector2.UnitY / 65f, dustType); + dust.scale = Main.rand.NextFloat(1.2f, 1.8f) * (modPlayer.fleshTotemManaStorage * 0.0009f) - rotMulti * 0.1f; + dust.noGravity = true; + dust.velocity = new Vector2(0, -2).RotatedByRandom(rotMulti * 0.3f) * (Main.rand.NextFloat(1f, 3.2f) - rotMulti) * (modPlayer.fleshTotemManaStorage * 0.0009f); + dust.alpha = 1; + dust.color = Color.Cyan; + } + int pulseMax = 360; + if (modPlayer.fleshTotemManaStorage == 0) + pulseMax = 360; + else + { + pulseMax = 360 - (modPlayer.fleshTotemManaStorage / 2); + + if (pulseMax < 60) + { + pulseMax = 60; + } + } + if (pulseTimer >= pulseMax) + { + //Main.NewText(pulseMax); + SoundEngine.PlaySound(BrimstoneElemental.HellfireballSound, Projectile.Center); + int manaGained = 30; + player.statMana += manaGained; + if (Main.myPlayer == player.whoAmI) + player.ManaEffect(manaGained); + + if (player.statMana > player.statManaMax2) + player.statMana = player.statManaMax2; + pulseTimer = 0; + } + pulseTimer++; + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Magic/VoidVortexProj.cs b/Projectiles/Magic/VoidVortexProj.cs index c0a5cfbf3f..435863a8cc 100644 --- a/Projectiles/Magic/VoidVortexProj.cs +++ b/Projectiles/Magic/VoidVortexProj.cs @@ -172,7 +172,6 @@ namespace CalamityMod.Projectiles.Magic } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 180); if (hit.Damage > 1 && Projectile.ai[2] == 3) Projectile.Kill(); }