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 0000000000..8e2d2a871c Binary files /dev/null and b/ExtraTextures/Particles/Light.png differ diff --git a/Items/BrimstoneLocus.cs b/Items/BrimstoneLocus.cs new file mode 100644 index 0000000000..d30495e93c --- /dev/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 0000000000..fae3b78655 Binary files /dev/null and b/Items/BrimstoneLocus.png differ diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 9a3773413d..13a0015304 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -4,10 +4,12 @@ using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Potions; +using CalamityMod.Items.SummonItems; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.Other; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Particles; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; @@ -18,12 +20,15 @@ using CalamityMod.UI; using CalamityMod.UI.CalamitasEnchants; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; +using System.Collections.Generic; using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.IO; +using Terraria.UI; namespace CalamityMod.Items { @@ -82,6 +87,7 @@ namespace CalamityMod.Items public CalamityGlobalItem() { StealthGenBonus = 1f; + EnchantmentEnergyParticles = new ChargingEnergyParticleSet(-1, 2, Color.DarkViolet, Color.White, 0.04f, 24f); } public override GlobalItem Clone(Item item, Item itemClone) @@ -481,10 +487,10 @@ namespace CalamityMod.Items } return true; } - #endregion + #endregion - #region SavingAndLoading - public override bool NeedsSaving(Item item) + #region SavingAndLoading + public override bool NeedsSaving(Item item) { return true; } @@ -1685,6 +1691,46 @@ namespace CalamityMod.Items } #endregion + #region Inventory Drawing + internal ChargingEnergyParticleSet EnchantmentEnergyParticles; + + public override bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + void drawItemManually(Color color, float generalScale) + { + Texture2D itemTexture = Main.itemTexture[item.type]; + Rectangle itemFrame = (Main.itemAnimations[item.type] == null) ? itemTexture.Frame(1, 1, 0, 0) : Main.itemAnimations[item.type].GetFrame(itemTexture); + Vector2 itemOrigin = itemFrame.Size() * 0.5f; + spriteBatch.Draw(itemTexture, position, itemFrame, color, 0f, itemOrigin, scale * generalScale, SpriteEffects.None, 0f); + } + + if (!EnchantmentManager.ItemUpgradeRelationship.ContainsKey(item.type) || !Main.LocalPlayer.InventoryHas(ModContent.ItemType())) + 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 0000000000..96d3b0caf3 Binary files /dev/null and b/Items/Weapons/Summon/Something.png differ 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; + } } }