From f91c2fe215ac173ce1b126ecb2a4a79390b0cbe8 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Wed, 19 May 2021 19:15:24 -0500 Subject: [PATCH] Entropy's vigil upgrade and Brimstone Locus --- CalPlayer/CalamityPlayer.cs | 3 + ExtraTextures/Particles/Light.png | Bin 0 -> 2903 bytes Items/BrimstoneLocus.cs | 35 ++++++ Items/BrimstoneLocus.png | Bin 0 -> 295 bytes Items/CalamityGlobalItem.cs | 52 +++++++- Items/Weapons/Summon/Something.cs | 50 ++++++++ Items/Weapons/Summon/Something.png | Bin 0 -> 477 bytes NPCs/TownNPCs/WITCH.cs | 7 ++ Particles/EnchantedParticleSet.cs | 45 +++++++ Projectiles/Melee/TaintedBladeSlasher.cs | 8 +- Projectiles/Summon/CataclysmSummon.cs | 115 ++++++++++++++++++ Projectiles/Summon/CatastropheSummon.cs | 51 ++++++++ .../CalamitasEnchantUI.cs | 39 ++++-- .../EnchantmentManager.cs | 27 +++- 14 files changed, 416 insertions(+), 16 deletions(-) create mode 100644 ExtraTextures/Particles/Light.png create mode 100644 Items/BrimstoneLocus.cs create mode 100644 Items/BrimstoneLocus.png create mode 100644 Items/Weapons/Summon/Something.cs create mode 100644 Items/Weapons/Summon/Something.png create mode 100644 Particles/EnchantedParticleSet.cs create mode 100644 Projectiles/Summon/CataclysmSummon.cs create mode 100644 Projectiles/Summon/CatastropheSummon.cs diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index d4bc8d64d5..eaa8000d18 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -114,6 +114,7 @@ namespace CalamityMod.CalPlayer public int defenseDamage = 0; public float rangedAmmoCost = 1f; public bool heldGaelsLastFrame = false; + public bool GivenBrimstoneLocus = false; #endregion #region Tile Entity Trackers @@ -1103,6 +1104,7 @@ namespace CalamityMod.CalPlayer boost.AddWithCondition("newAmidiasInventory", newAmidiasInventory); boost.AddWithCondition("newBanditInventory", newBanditInventory); boost.AddWithCondition("newCalamitasInventory", newCalamitasInventory); + boost.AddWithCondition("GivenBrimstoneLocus", GivenBrimstoneLocus); return new TagCompound { @@ -1179,6 +1181,7 @@ namespace CalamityMod.CalPlayer newAmidiasInventory = boost.Contains("newAmidiasInventory"); newBanditInventory = boost.Contains("newBanditInventory"); newCalamitasInventory = boost.Contains("newCalamitasInventory"); + GivenBrimstoneLocus = boost.Contains("GivenBrimstoneLocus"); // Load rage from "stress" if this is an older save. Otherwise load it from "rage", its new name. if (tag.ContainsKey("stress")) diff --git a/ExtraTextures/Particles/Light.png b/ExtraTextures/Particles/Light.png new file mode 100644 index 0000000000000000000000000000000000000000..8e2d2a871cdedc2f8035aec442b4c527a2bf3160 GIT binary patch literal 2903 zcmV-d3#jyoP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D3hYTlK~#8N?VRg# z6Ui0Dv1}RH^80Pfn}w}p$tGU|e95NB9~~;2$_7#uDx0d^u=&6e9)5r=Sue{ESuf}O z?(`LsY%^XKQnlGRra3b`Gq-Q|J-Xe~G7Oyi-=U|i0U;co2}eRWbo8Hp6r=(tI0YY5 zL1x>Pk`iFYpa91y$(7R*tRkQ-z+KAvD2hrH6oU_`pdQ7zLL7dcPN#>%xdmr16_k`3 z=n2+Q`^Xg1YDdbEfb6`{Xw<`bkD~niLn|s#Pz-*If_k2Hh4d?ESO|O`J}-2i52w?{ z5>ijFBpg#rz0o){uGftZh3<24kD^>be%^)mQdFX#7`%^y?3sS0ID3v65#WpfkB*LJ z;j93UkB?8n5|mvZ5@1JDfF+n3T&-3s@SXtg@9!Je1o%LJ`*W1@`{t%ZK{5Ct3OZ3a zT{*^B0vUtH#>U3ssi~>yZk`Cr8K0P#fJZVJQv6m(FlnNq4dJ3H`BP*S;E zE_L(n?rs&9z;@pX(V#}(j;S(sl~f)^JTOfkRw?6ceOty{Nl!eiNNlzTL- z!RLpEZ5Gq)*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null +++ b/Items/BrimstoneLocus.cs @@ -0,0 +1,35 @@ +using CalamityMod.Items.Materials; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items +{ + public class BrimstoneLocus : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brimstone Locus"); + Tooltip.SetDefault("Not only can I enhance your equipment with potent magic, I can also draw out the true strength and ascend\n" + + "some of your weaponry to entirely new forms\n" + + "Such items are revealed while this item is in your inventory"); + } + + public override void SetDefaults() + { + item.width = 20; + item.height = 20; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.value = 0; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/BrimstoneLocus.png b/Items/BrimstoneLocus.png new file mode 100644 index 0000000000000000000000000000000000000000..fae3b786552cd8d03b5413f9b8d64b7a8511d72e GIT binary patch literal 295 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX3?zBp#Z3TGjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCf`V@Ck7R(qeqdwi>p+mTnpn28m*p|0fnd_V-_F;s%sDbIvLUNO6?}`33)n z0ftRybj|}sISV`@iy0XB4ude`@%$AjK*1VM7sn6_|D_WS@-ZuNxNtjN{r~@=(K)qS z-p03U#ZTBY9lZYMP}l0%I~UX5`Ilt-f7ze^SVhmCz2xmZuJ0YT3$oTdFKY6+8uPAO z<6TxmzM@Yk@0oLp8&(wy9;|9zbgo8x@B33R7iV%99e=@U&6iOn60$qkl())) + return true; + + // Create particle positions as necessary. + EnchantmentEnergyParticles.Update(); + + // Draw all particles. + float currentPower = 0f; + int calamitasNPCIndex = NPC.FindFirstNPC(ModContent.NPCType()); + if (calamitasNPCIndex != -1) + currentPower = Utils.InverseLerp(11750f, 1000f, Main.LocalPlayer.Distance(Main.npc[calamitasNPCIndex].Center), true); + + position += Vector2.One * 14f; + EnchantmentEnergyParticles.InterpolationSpeed = MathHelper.Lerp(0.035f, 0.1f, currentPower); + EnchantmentEnergyParticles.DrawSet(position + Main.screenPosition); + + float pulse = Main.GlobalTime * 0.79f % 1f; + float pulseFade = Utils.InverseLerp(0.87f, 0.27f, pulse, true); + float pulseScale = scale * MathHelper.Lerp(1.6f, 1f, pulseFade) / scale; + Color pulseColor = Color.Lerp(drawColor, Color.BlueViolet, pulseFade) * pulseFade; + drawItemManually(pulseColor, pulseScale); + drawItemManually(drawColor, 1f); + + return false; + } + #endregion + #region Reforging private int NewPrefixType(Item item) { diff --git a/Items/Weapons/Summon/Something.cs b/Items/Weapons/Summon/Something.cs new file mode 100644 index 0000000000..7accc71ebf --- /dev/null +++ b/Items/Weapons/Summon/Something.cs @@ -0,0 +1,50 @@ +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class Something : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Something"); + Tooltip.SetDefault("Summons either Cataclysm or Catastrophe at the mouse position\n" + + "They will look at you for a moment before charging at you\n" + + "They can do damage to both you and enemies"); + } + + public override void SetDefaults() + { + item.mana = 100; + item.damage = 16660; + item.useStyle = ItemUseStyleID.SwingThrow; + item.width = 58; + item.height = 64; + item.useTime = item.useAnimation = 30; + item.autoReuse = true; + item.noMelee = true; + item.knockBack = 0f; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.Violet; + item.UseSound = SoundID.DD2_BetsySummon; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + } + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + if (player.altFunctionUse != 2) + { + if (Main.rand.NextBool(2)) + type = ModContent.ProjectileType(); + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); + } + return false; + } + } +} diff --git a/Items/Weapons/Summon/Something.png b/Items/Weapons/Summon/Something.png new file mode 100644 index 0000000000000000000000000000000000000000..96d3b0caf3147fdefbac73e05553e25a2a1f232d GIT binary patch literal 477 zcmeAS@N?(olHy`uVBq!ia0vp^RzU2)!3-p8?o8PWq!^2X+?^QKos)S9s|5IjxB}__%uLa0YEQY=NsG&_F>%#aP-rnS`rqjO?_6Q1iVjdg*N2je zK#Hd%$S?Rm0x$^OKX(o&&RO6QSEamT;l20T?YzSZ0vg( z;LUxvM{KeOr_5$9SYwvT#)(Hm86OaZ5C4;A{ KpUXO@geCx`1k6$Z literal 0 HcmV?d00001 diff --git a/NPCs/TownNPCs/WITCH.cs b/NPCs/TownNPCs/WITCH.cs index a370b8fde1..161db7bccd 100644 --- a/NPCs/TownNPCs/WITCH.cs +++ b/NPCs/TownNPCs/WITCH.cs @@ -1,4 +1,5 @@ using CalamityMod.Dusts; +using CalamityMod.Items; using CalamityMod.Projectiles.Magic; using CalamityMod.UI.CalamitasEnchants; using CalamityMod.World; @@ -133,6 +134,12 @@ namespace CalamityMod.NPCs.TownNPCs CalamitasEnchantUI.NPCIndex = npc.whoAmI; CalamitasEnchantUI.CurrentlyViewing = true; + if (!Main.LocalPlayer.Calamity().GivenBrimstoneLocus) + { + DropHelper.DropItem(npc, ItemType()); + Main.LocalPlayer.Calamity().GivenBrimstoneLocus = true; + } + shop = false; } } diff --git a/Particles/EnchantedParticleSet.cs b/Particles/EnchantedParticleSet.cs new file mode 100644 index 0000000000..4feb625237 --- /dev/null +++ b/Particles/EnchantedParticleSet.cs @@ -0,0 +1,45 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class ChargingEnergyParticleSet : BaseParticleSet + { + public float InterpolationSpeed; + public float EdgeOffset; + public Color EdgeColor; + public Color CenterColor; + public override int ParticleLifetime => 50; + public override Texture2D ParticleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Particles/Light"); + public ChargingEnergyParticleSet(int setLifetime, int particleSpawnRate, Color edgeColor, Color centerColor, float interpolationSpeed, float edgeOffset) : + base(setLifetime, particleSpawnRate) + { + EdgeColor = edgeColor; + CenterColor = centerColor; + InterpolationSpeed = interpolationSpeed; + EdgeOffset = edgeOffset; + } + + public override void UpdateBehavior(Particle particle) + { + float distanceToCenter = particle.RelativeOffset.Length(); + particle.Scale = MathHelper.SmoothStep(0.05f, 0.125f, Utils.InverseLerp(EdgeOffset, 6f, distanceToCenter, true)); + particle.Scale *= Utils.InverseLerp(ParticleLifetime, ParticleLifetime - 10f, particle.Time, true); + + if (distanceToCenter > 4.5f) + particle.RelativeOffset = Vector2.Lerp(particle.RelativeOffset, Vector2.Zero, InterpolationSpeed); + } + + public override Color DetermineParticleColor(float lifetimeCompletion) + { + Color particleColor = Color.Lerp(EdgeColor, CenterColor, Utils.InverseLerp(0f, 0.67f, lifetimeCompletion, true)); + particleColor.A = 50; + + return particleColor; + } + + public override Particle SpawnParticle() => new Particle(ParticleLifetime, Main.rand.NextVector2CircularEdge(1f, 1f) * EdgeOffset, 0.1f); + } +} \ No newline at end of file diff --git a/Projectiles/Melee/TaintedBladeSlasher.cs b/Projectiles/Melee/TaintedBladeSlasher.cs index 3958b3a93c..5634fdf373 100644 --- a/Projectiles/Melee/TaintedBladeSlasher.cs +++ b/Projectiles/Melee/TaintedBladeSlasher.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Projectiles.Melee public ref float Time => ref projectile.localAI[1]; public float AttackCompletionRatio => 1f - Owner.itemAnimation / (float)Owner.itemAnimationMax; public Player Owner => Main.player[projectile.owner]; - public int Variant => projectile.identity % 2; + public int Variant => (int)projectile.ai[0] % 2; public const float ForearmLength = 80f; public const float ArmLength = 108f; @@ -117,11 +117,12 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { CalamityPlayerMiscEffects.EnchantHeldItemEffects(Owner, Owner.Calamity(), Owner.ActiveItem()); - if (!Owner.Calamity().bladeArmEnchant) + if (!Owner.Calamity().bladeArmEnchant || Owner.CCed || !Owner.active || Owner.dead) { projectile.Kill(); return; } + float swingOffsetAngle = MathHelper.SmoothStep(-1.87f, 3.79f, AttackCompletionRatio); // Offset a little bit angularly if the secondary variant to prevent complete overlap. @@ -174,6 +175,9 @@ namespace CalamityMod.Projectiles.Melee if (projectile.Center != destination) projectile.Center += (destination - projectile.Center).SafeNormalize(Vector2.Zero) * MathHelper.Min(projectile.Distance(destination), 12f + Owner.velocity.Length()); + // Ensure that the position is never too far from the destination. + CalamityUtils.DistanceClamp(ref projectile.position, ref destination, 50f); + Time++; } diff --git a/Projectiles/Summon/CataclysmSummon.cs b/Projectiles/Summon/CataclysmSummon.cs new file mode 100644 index 0000000000..36beeecad4 --- /dev/null +++ b/Projectiles/Summon/CataclysmSummon.cs @@ -0,0 +1,115 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class CataclysmSummon : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public bool LookingAtPlayer => Time < 45f; + public override string Texture => "CalamityMod/NPCs/SupremeCalamitas/SupremeCataclysm"; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cataclysm"); + Main.projFrames[projectile.type] = 6; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.MinionSacrificable[projectile.type] = false; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = false; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 100; + projectile.netImportant = true; + projectile.friendly = true; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.minionSlots = 0f; + projectile.timeLeft = 90000; + projectile.penetrate = -1; + projectile.Opacity = 0f; + projectile.tileCollide = false; + projectile.minion = true; + } + + public override void AI() => Behavior(projectile, Main.player[projectile.owner], ref Time); + + public static void Behavior(Projectile projectile, Player owner, ref float time) + { + DoFrameEffects(projectile); + + if (time < 40f) + FadeIn(projectile); + + else if (time > 95f) + { + projectile.Opacity -= 0.06f; + if (projectile.Opacity < 0f) + projectile.Kill(); + } + + if (time < 25f) + { + float idealRotation = projectile.AngleTo(owner.Center) - MathHelper.PiOver2; + projectile.rotation = projectile.rotation.AngleLerp(idealRotation, 0.08f); + projectile.rotation = projectile.rotation.AngleTowards(idealRotation, 0.2f); + } + else if (time < 40f) + { + projectile.rotation = projectile.AngleTo(owner.Center) - MathHelper.PiOver2; + projectile.velocity = projectile.SafeDirectionTo(owner.Center) * -5f; + } + else if (time == 40f) + { + projectile.rotation = projectile.AngleTo(owner.Center) - MathHelper.PiOver2; + projectile.velocity = projectile.SafeDirectionTo(owner.Center) * 31f; + projectile.damage = (int)(projectile.damage * 1.45); + + Main.PlaySound(SoundID.DD2_BetsyFlameBreath, owner.Center); + Main.PlaySound(SoundID.DD2_WyvernDiveDown, owner.Center); + } + + time++; + } + + public static void FadeIn(Projectile projectile) + { + if (projectile.localAI[0] == 0f) + { + for (int i = 0; i < 40; i++) + { + Dust brimstone = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Square(-65f, 65f), 267); + brimstone.velocity = -Vector2.UnitY * Main.rand.NextFloat(1.8f, 3.6f); + brimstone.scale = Main.rand.NextFloat(1.65f, 1.85f); + brimstone.fadeIn = Main.rand.NextFloat(0.7f, 0.9f); + brimstone.color = Color.Red; + brimstone.noGravity = true; + } + projectile.localAI[0] = 1f; + } + + projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.075f, 0f, 1f); + } + + public static void DoFrameEffects(Projectile projectile) + { + projectile.frameCounter++; + if (projectile.frameCounter % 5f == 4f) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], Color.Red, 1); + return true; + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) => damage = 70; + + public override bool CanDamage() => projectile.Opacity >= 1f; + } +} diff --git a/Projectiles/Summon/CatastropheSummon.cs b/Projectiles/Summon/CatastropheSummon.cs new file mode 100644 index 0000000000..d60bdafa56 --- /dev/null +++ b/Projectiles/Summon/CatastropheSummon.cs @@ -0,0 +1,51 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class CatastropheSummon : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public bool LookingAtPlayer => Time < 45f; + public override string Texture => "CalamityMod/NPCs/SupremeCalamitas/SupremeCatastrophe"; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Catastrophe"); + Main.projFrames[projectile.type] = 6; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.MinionSacrificable[projectile.type] = false; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = false; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 120; + projectile.netImportant = true; + projectile.friendly = true; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.minionSlots = 0f; + projectile.timeLeft = 90000; + projectile.penetrate = -1; + projectile.Opacity = 0f; + projectile.tileCollide = false; + projectile.minion = true; + } + + public override void AI() => CataclysmSummon.Behavior(projectile, Main.player[projectile.owner], ref Time); + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], Color.Red, 1); + return true; + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) => damage = 70; + + public override bool CanDamage() => projectile.Opacity >= 1f; + } +} diff --git a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs index 47f77b4606..2be7d5e39d 100644 --- a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs +++ b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs @@ -162,6 +162,11 @@ namespace CalamityMod.UI.CalamitasEnchants return 0; int cost = CurrentlyHeldItem.value * 4; + + // Increase the cost of enchanting significantly if doing so would upgrade the item directly. + if (SelectedEnchantment.HasValue && SelectedEnchantment.Value.Name == "Curse") + cost = (int)MathHelper.Min(cost, Item.buyPrice(5)) * 5; + ItemSlot.DrawMoney(spriteBatch, "Cost: ", costDrawPositionTopLeft.X, costDrawPositionTopLeft.Y, Utils.CoinsSplit(cost)); return cost; @@ -234,6 +239,9 @@ namespace CalamityMod.UI.CalamitasEnchants itemScale *= inventoryScale * baseScale; drawPosition += Vector2.One * 23f * baseScale; + if (EnchantmentManager.ItemUpgradeRelationship.ContainsKey(CurrentlyHeldItem.type)) + drawPosition -= Vector2.One * 12f; + // Draw the item. if (hasMultipleFrames || ItemLoader.PreDrawInInventory(CurrentlyHeldItem, spriteBatch, drawPosition, itemFrame, CurrentlyHeldItem.GetAlpha(Color.White), CurrentlyHeldItem.GetColor(Color.White), itemTexture.Size() * 0.5f, itemScale)) { @@ -326,22 +334,30 @@ namespace CalamityMod.UI.CalamitasEnchants if (CurrentlyHeldItem.IsAir) return; - // If there is no cost or the player cannot afford it, do nothing. - if (cost <= 0L || !Main.LocalPlayer.CanBuyItem(cost)) - return; - // If no enchantment has been selected, do nothing. if (!SelectedEnchantment.HasValue) return; + // If there is no cost or the player cannot afford it, do nothing. + if (cost <= 0 || !Main.LocalPlayer.CanBuyItem(cost)) + return; + Item originalItem = CurrentlyHeldItem.Clone(); byte oldPrefix = CurrentlyHeldItem.prefix; CurrentlyHeldItem.SetDefaults(CurrentlyHeldItem.type); CurrentlyHeldItem.Prefix(oldPrefix); CurrentlyHeldItem = CurrentlyHeldItem.CloneWithModdedDataFrom(originalItem); - CurrentlyHeldItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value; - SelectedEnchantment.Value.CreationEffect?.Invoke(CurrentlyHeldItem); + if (SelectedEnchantment.Value.Name == "Curse") + { + CurrentlyHeldItem.SetDefaults(EnchantmentManager.ItemUpgradeRelationship[CurrentlyHeldItem.type]); + CurrentlyHeldItem.Prefix(oldPrefix); + } + else + { + CurrentlyHeldItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value; + SelectedEnchantment.Value.CreationEffect?.Invoke(CurrentlyHeldItem); + } // Update the compare item. This is used check comparisons when showing reforge tooltip bonuses. // Updating it with the same bonuses as what was applied to the real item will negate the incorrect numbers, @@ -349,8 +365,12 @@ namespace CalamityMod.UI.CalamitasEnchants if (Main.cpItem is null) Main.cpItem = new Item(); Main.cpItem.SetDefaults(Main.cpItem.type); - Main.cpItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value; - SelectedEnchantment.Value.CreationEffect?.Invoke(Main.cpItem); + + if (SelectedEnchantment.Value.Name != "Curse") + { + Main.cpItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value; + SelectedEnchantment.Value.CreationEffect?.Invoke(Main.cpItem); + } // Take away the money for the cost. Main.LocalPlayer.BuyItem(cost); @@ -359,6 +379,9 @@ namespace CalamityMod.UI.CalamitasEnchants EnchantIndex = 0; Main.PlaySound(SoundID.DD2_BetsyFlameBreath, Main.LocalPlayer.Center); + + if (SelectedEnchantment.Value.Name == "Curse") + Main.PlaySound(SoundID.DD2_DarkMageHealImpact, Main.LocalPlayer.Center); } } } diff --git a/UI/CalamitasEnchantments/EnchantmentManager.cs b/UI/CalamitasEnchantments/EnchantmentManager.cs index 73fd142398..f86efb6f3e 100644 --- a/UI/CalamitasEnchantments/EnchantmentManager.cs +++ b/UI/CalamitasEnchantments/EnchantmentManager.cs @@ -1,3 +1,4 @@ +using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using System; @@ -13,6 +14,7 @@ namespace CalamityMod.UI.CalamitasEnchants { internal const int ClearEnchantmentID = -18591774; public static List EnchantmentList { get; internal set; } = new List(); + public static Dictionary ItemUpgradeRelationship { get; internal set; } = new Dictionary(); public static Enchantment ClearEnchantment { get; internal set; } public static IEnumerable GetValidEnchantmentsForItem(Item item) { @@ -20,6 +22,10 @@ namespace CalamityMod.UI.CalamitasEnchants if (item is null || item.IsAir || !item.CanBeEnchantedBySomething()) yield break; + // Don't allow any enchantments if the item is an upgrade item. + if (ItemUpgradeRelationship.ContainsValue(item.type)) + yield break; + // Only give the option to clear if the item already has an enchantment. if (item.Calamity().AppliedEnchantment.HasValue) { @@ -127,6 +133,12 @@ namespace CalamityMod.UI.CalamitasEnchants { EnchantmentList = new List { + new Enchantment("Curse", "Transforms this item into something significantly better.", + 1, + null, + null, + item => ItemUpgradeRelationship.ContainsKey(item.type)), + new Enchantment("Cursed", "Summons demons that harm you but drop healing items on death on item usage.", 100, null, @@ -194,11 +206,11 @@ namespace CalamityMod.UI.CalamitasEnchants { // Yes, this is a LOT of damage but given the limited range of this thing it needs to be extremely powerful when it does actually hit. int damage = (int)(player.ActiveItem().damage * player.MeleeDamage() * 5); - int blade = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 1, player.ActiveItem().type); + int blade = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, player.ActiveItem().type); if (Main.projectile.IndexInRange(blade)) Main.projectile[blade].localAI[0] = 0f; - blade = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, -1, player.ActiveItem().type); + blade = Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 1f, player.ActiveItem().type); if (Main.projectile.IndexInRange(blade)) Main.projectile[blade].localAI[0] = -80f; } @@ -216,8 +228,17 @@ namespace CalamityMod.UI.CalamitasEnchants ClearEnchantment = new Enchantment("Disenchant", string.Empty, ClearEnchantmentID, item => item.Calamity().AppliedEnchantment = null, item => item.maxStack == 1 && item.shoot >= ProjectileID.None); + + ItemUpgradeRelationship = new Dictionary() + { + [ModContent.ItemType()] = ModContent.ItemType() + }; } - public static void UnloadAllEnchantments() => EnchantmentList = null; + public static void UnloadAllEnchantments() + { + EnchantmentList = null; + ItemUpgradeRelationship = null; + } } }