diff --git a/Buffs/Cooldowns/Withered.cs b/Buffs/Cooldowns/Withered.cs new file mode 100644 index 0000000000..5a68168394 --- /dev/null +++ b/Buffs/Cooldowns/Withered.cs @@ -0,0 +1,21 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Cooldowns +{ + public class Withered : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Withered"); + Description.SetDefault("Holding withered weapons causes you to suffer but makes your weapons strong"); + 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().witheredDebuff = true; + } +} diff --git a/Buffs/Cooldowns/Withered.png b/Buffs/Cooldowns/Withered.png new file mode 100644 index 0000000000..c51dae7b2a Binary files /dev/null and b/Buffs/Cooldowns/Withered.png differ diff --git a/Buffs/DamageOverTime/VulnerabilityHex.cs b/Buffs/DamageOverTime/VulnerabilityHex.cs index 005efdf936..dfc4a2c6e0 100644 --- a/Buffs/DamageOverTime/VulnerabilityHex.cs +++ b/Buffs/DamageOverTime/VulnerabilityHex.cs @@ -16,10 +16,7 @@ namespace CalamityMod.Buffs.DamageOverTime canBeCleared = false; } - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().vHex = true; - } + public override void Update(Player player, ref int buffIndex) => player.Calamity().vHex = true; public override void Update(NPC npc, ref int buffIndex) { diff --git a/Buffs/DamageOverTime/WeakBrimstoneFlames.cs b/Buffs/DamageOverTime/WeakBrimstoneFlames.cs new file mode 100644 index 0000000000..edf6f12830 --- /dev/null +++ b/Buffs/DamageOverTime/WeakBrimstoneFlames.cs @@ -0,0 +1,21 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.DamageOverTime +{ + public class WeakBrimstoneFlames : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Weak Brimstone Flames"); + Description.SetDefault("Health loss"); + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + longerExpertDebuff = false; + } + + public override void Update(Player player, ref int buffIndex) => player.Calamity().weakBrimstoneFlames = true; + } +} diff --git a/Buffs/DamageOverTime/WeakBrimstoneFlames.png b/Buffs/DamageOverTime/WeakBrimstoneFlames.png new file mode 100644 index 0000000000..e2be863c4b Binary files /dev/null and b/Buffs/DamageOverTime/WeakBrimstoneFlames.png differ diff --git a/Buffs/Summon/SepulcherMinionBuff.cs b/Buffs/Summon/SepulcherMinionBuff.cs new file mode 100644 index 0000000000..34910472ba --- /dev/null +++ b/Buffs/Summon/SepulcherMinionBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class SepulcherMinionBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Sepulcher"); + Description.SetDefault("It is not benevolent"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + //Main.persistentBuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.sepulcher = true; + + if (!modPlayer.sepulcher) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/SepulcherMinionBuff.png b/Buffs/Summon/SepulcherMinionBuff.png new file mode 100644 index 0000000000..5eeae4fa2b Binary files /dev/null and b/Buffs/Summon/SepulcherMinionBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index f3da624b30..56da8d95c2 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -31,6 +31,7 @@ using CalamityMod.NPCs.DevourerofGods; using CalamityMod.NPCs.GreatSandShark; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.Other; using CalamityMod.NPCs.PlaguebringerGoliath; using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.Polterghast; @@ -122,6 +123,7 @@ namespace CalamityMod.CalPlayer public bool ableToDrawBlazingMouse = false; public float blazingMouseAuraFade = 0f; public float GeneralScreenShakePower = 0f; + public bool GivenBrimstoneLocus = false; #endregion #region Tile Entity Trackers @@ -161,6 +163,7 @@ namespace CalamityMod.CalPlayer public bool newCirrusInventory = false; public bool newAmidiasInventory = false; public bool newBanditInventory = false; + public bool newCalamitasInventory = false; #endregion #region Stat Meter @@ -724,6 +727,7 @@ namespace CalamityMod.CalPlayer public bool aCrunch = false; public bool irradiated = false; public bool bFlames = false; + public bool weakBrimstoneFlames = false; public bool aFlames = false; public bool gsInferno = false; public bool astralInfection = false; @@ -937,6 +941,7 @@ namespace CalamityMod.CalPlayer public bool plaguebringerPatronSummon = false; public bool howlTrio = false; public bool mountedScanner = false; + public bool sepulcher = false; public bool daedalusGolem = false; public bool deathstareEyeball = false; public bool witherBlossom = false; @@ -1021,6 +1026,27 @@ namespace CalamityMod.CalPlayer public bool omegaBlueTransformationPower; #endregion + #region Calamitas Enchant Effects + public bool cursedSummonsEnchant = false; + public bool flamingItemEnchant = false; + public bool lifeManaEnchant = false; + public bool farProximityRewardEnchant = false; + public bool closeProximityRewardEnchant = false; + public bool dischargingItemEnchant = false; + public bool explosiveMinionsEnchant = false; + public bool bladeArmEnchant = false; + public bool manaMonsterEnchant = false; + + public bool witheringWeaponEnchant = false; + public bool witheredDebuff = false; + public int witheredWeaponHoldTime = 0; + + public bool persecutedEnchant = false; + public int persecutedEnchantSummonTimer = 0; + + public bool lecherousOrbEnchant = false; + #endregion Calamitas Enchant Effects + #endregion #region SavingAndLoading @@ -1068,6 +1094,7 @@ namespace CalamityMod.CalPlayer newCirrusInventory = false; newAmidiasInventory = false; newBanditInventory = false; + newCalamitasInventory = false; } public override TagCompound Save() @@ -1116,6 +1143,8 @@ namespace CalamityMod.CalPlayer boost.AddWithCondition("newCirrusInventory", newCirrusInventory); boost.AddWithCondition("newAmidiasInventory", newAmidiasInventory); boost.AddWithCondition("newBanditInventory", newBanditInventory); + boost.AddWithCondition("newCalamitasInventory", newCalamitasInventory); + boost.AddWithCondition("GivenBrimstoneLocus", GivenBrimstoneLocus); return new TagCompound { @@ -1191,6 +1220,8 @@ namespace CalamityMod.CalPlayer newCirrusInventory = boost.Contains("newCirrusInventory"); 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")) @@ -1324,8 +1355,9 @@ namespace CalamityMod.CalPlayer BitsByte flags6 = reader.ReadByte(); newBanditInventory = flags6[0]; - finalTierAccessoryReforge = flags6[1]; - } + finalTierAccessoryReforge = flags6[1]; + newCalamitasInventory = flags6[2]; + } else { ModContent.GetInstance().Logger.Error("Unknown loadVersion: " + loadVersion); @@ -1755,6 +1787,7 @@ namespace CalamityMod.CalPlayer aCrunch = false; irradiated = false; bFlames = false; + weakBrimstoneFlames = false; aFlames = false; gsInferno = false; astralInfection = false; @@ -1973,6 +2006,7 @@ namespace CalamityMod.CalPlayer plaguebringerPatronSummon = false; howlTrio = false; mountedScanner = false; + sepulcher = false; daedalusGolem = false; deathstareEyeball = false; witherBlossom = false; @@ -2007,9 +2041,23 @@ namespace CalamityMod.CalPlayer RageDuration = DefaultRageDuration; RageDamageBoost = DefaultRageDamageBoost; + cursedSummonsEnchant = false; + flamingItemEnchant = false; + lifeManaEnchant = false; + farProximityRewardEnchant = false; + closeProximityRewardEnchant = false; + dischargingItemEnchant = false; + explosiveMinionsEnchant = false; + bladeArmEnchant = false; + manaMonsterEnchant = false; + witheringWeaponEnchant = false; + persecutedEnchant = false; + lecherousOrbEnchant = false; flatStealthLossReduction = 0; lastProjectileHit = null; + + CalamityPlayerMiscEffects.EnchantHeldItemEffects(player, player.Calamity(), player.ActiveItem()); } #endregion @@ -2119,6 +2167,7 @@ namespace CalamityMod.CalPlayer aCrunch = false; irradiated = false; bFlames = false; + weakBrimstoneFlames = false; aFlames = false; gsInferno = false; astralInfection = false; @@ -2413,6 +2462,7 @@ namespace CalamityMod.CalPlayer animusBoost = 1f; potionTimer = 0; bloodflareCoreLostDefense = 0; + persecutedEnchantSummonTimer = 0; if (BossRushEvent.BossRushActive) { @@ -4410,7 +4460,7 @@ namespace CalamityMod.CalPlayer else damageSource = PlayerDeathReason.ByCustomReason(player.name + "'s lungs collapsed."); } - if (bFlames || aFlames) + if (bFlames || aFlames || weakBrimstoneFlames) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was consumed by the black flames."); } @@ -4556,7 +4606,7 @@ namespace CalamityMod.CalPlayer else acidRoundMultiplier = 1D; - //Prismatic Breaker is a weird hybrid melee-ranged weapon so include it too. Why are you using desert prowler post-Yharon? don't ask me + // Prismatic Breaker is a weird hybrid melee-ranged weapon so include it too. Why are you using desert prowler post-Yharon? don't ask me if (desertProwler && (item.ranged || item.type == ModContent.ItemType()) && item.ammo == AmmoID.None) flat += 1f; } @@ -6871,6 +6921,9 @@ namespace CalamityMod.CalPlayer #region Shoot public override bool Shoot(Item item, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { + if (bladeArmEnchant) + return false; + if (rottenDogTooth && item.Calamity().rogue && item.type != ModContent.ItemType()) damage = (int)(damage * (1f + RottenDogtooth.StealthStrikeDamageMultiplier)); @@ -7305,6 +7358,15 @@ namespace CalamityMod.CalPlayer if (player.whoAmI == Main.myPlayer) { + // Summon a portal if needed. + if (player.Calamity().persecutedEnchant && NPC.CountNPCS(ModContent.NPCType()) < 2) + { + Vector2 spawnPosition = player.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(270f, 420f); + int portal = NPC.NewNPC((int)spawnPosition.X, (int)spawnPosition.Y, ModContent.NPCType()); + if (Main.npc.IndexInRange(portal)) + Main.npc[portal].target = player.whoAmI; + } + if (revivify) { int healAmt = (int)(damage / 15D); @@ -10666,5 +10728,32 @@ namespace CalamityMod.CalPlayer } #endregion + + #region Mana Consumption Effects + public override void OnConsumeMana(Item item, int manaConsumed) + { + CalamityPlayer modPlayer = player.Calamity(); + if (Main.rand.NextBool(4) && modPlayer.lifeManaEnchant) + { + if (Main.myPlayer == player.whoAmI) + { + player.HealEffect(-5); + player.statLife -= 5; + if (player.statLife <= 0) + player.KillMe(PlayerDeathReason.ByCustomReason($"{player.name} converted all of their life to mana."), 1000, -1); + } + + for (int i = 0; i < 8; i++) + { + Dust life = Dust.NewDustPerfect(player.Top + Main.rand.NextVector2Circular(player.width * 0.5f, 6f), 267); + life.color = Color.Red; + life.velocity = -Vector2.UnitY.RotatedByRandom(0.48f) * Main.rand.NextFloat(3f, 4.4f); + life.scale = Main.rand.NextFloat(1.5f, 1.72f); + life.fadeIn = 0.7f; + life.noGravity = true; + } + } + } + #endregion } } diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 5eaaf80cc2..3dfb8137f3 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -2,10 +2,10 @@ using CalamityMod.Buffs.Alcohol; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Ranged; using CalamityMod.World; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ModLoader; @@ -95,6 +95,15 @@ namespace CalamityMod.CalPlayer lifeRegenLost += 16; } + if (modPlayer.weakBrimstoneFlames) + { + if (player.lifeRegen > 0) + player.lifeRegen = 0; + + player.lifeRegenTime = 0; + lifeRegenLost += 5; + } + if (modPlayer.bFlames) { if (player.lifeRegen > 0) @@ -400,7 +409,23 @@ namespace CalamityMod.CalPlayer if (player.lifeRegen > 0) player.lifeRegen = 0; lifeRegenLost += 42; //the meaning of death - } + } + if (modPlayer.witheredDebuff) + { + modPlayer.witheredWeaponHoldTime += modPlayer.witheringWeaponEnchant.ToDirectionInt(); + if (modPlayer.witheredWeaponHoldTime < 0) + { + modPlayer.witheredWeaponHoldTime = 0; + } + else + { + lifeRegenLost += (int)(4D * Math.Pow(1.5D, modPlayer.witheredWeaponHoldTime / 87D)); + if (player.lifeRegen > 0) + player.lifeRegen = 0; + } + } + else + modPlayer.witheredWeaponHoldTime = 0; player.lifeRegen -= (int)(lifeRegenLost * lifeRegenMult); @@ -653,6 +678,11 @@ namespace CalamityMod.CalPlayer player.lifeRegenTime += 1; player.lifeRegen += 2; } + else if (modPlayer.rOoze) + { + if (!Main.dayTime) + player.lifeRegen += 4; + } if (modPlayer.ursaSergeant) { diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index db106456cb..f7e789e900 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -7,6 +7,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Buffs.Summon; using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Items; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor; using CalamityMod.Items.Fishing.AstralCatches; @@ -21,6 +22,7 @@ using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.Other; using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.Projectiles.Boss; @@ -116,6 +118,11 @@ namespace CalamityMod.CalPlayer // Potions (Quick Buff && Potion Sickness) HandlePotions(player, modPlayer); + // Update all particle sets for items. + // This must be done here instead of in the item logic because these sets are not properly instanced + // in the global classes. Attempting to update them there will cause multiple updates to one set for multiple items. + CalamityGlobalItem.UpdateAllParticleSets(); + // Regularly sync player stats during multiplayer if (player.whoAmI == Main.myPlayer && Main.netMode == NetmodeID.MultiplayerClient) { @@ -344,7 +351,7 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < Main.maxNPCs; ++i) { NPC npc = Main.npc[i]; - if (npc is null || !npc.IsAnEnemy()) + if (npc is null || !npc.IsAnEnemy() || npc.Calamity().DoesNotGenerateRage) continue; // Take the longer of the two directions for the NPC's hitbox to be generous. @@ -1231,6 +1238,19 @@ namespace CalamityMod.CalPlayer modPlayer.aBulwarkRareTimer--; if (modPlayer.hellbornBoost > 0) modPlayer.hellbornBoost--; + if (modPlayer.persecutedEnchantSummonTimer < 1800) + modPlayer.persecutedEnchantSummonTimer++; + else + { + modPlayer.persecutedEnchantSummonTimer = 0; + if (Main.myPlayer == player.whoAmI && player.Calamity().persecutedEnchant && NPC.CountNPCS(ModContent.NPCType()) < 2) + { + Vector2 spawnPosition = player.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(270f, 420f); + int portal = NPC.NewNPC((int)spawnPosition.X, (int)spawnPosition.Y, ModContent.NPCType()); + if (Main.npc.IndexInRange(portal)) + Main.npc[portal].target = player.whoAmI; + } + } if (player.miscCounter % 20 == 0) modPlayer.canFireAtaxiaRangedProjectile = true; if (player.miscCounter % 100 == 0) @@ -1454,11 +1474,14 @@ namespace CalamityMod.CalPlayer // Ambrosial Ampoule bonus and other light-granting bonuses float[] light = new float[3]; - if (modPlayer.aAmpoule) + if ((modPlayer.rOoze && !Main.dayTime) || modPlayer.aAmpoule) { light[0] += 1f; light[1] += 1f; light[2] += 0.6f; + } + if (modPlayer.aAmpoule) + { player.endurance += 0.05f; player.pickSpeed -= 0.25f; player.buffImmune[BuffID.Venom] = true; @@ -2079,6 +2102,43 @@ namespace CalamityMod.CalPlayer } #endregion + #region Calamitas Enchantment Held Item Effects + public static void EnchantHeldItemEffects(Player player, CalamityPlayer modPlayer, Item heldItem) + { + if (heldItem.IsAir) + return; + + // Exhaustion recharge effects. + foreach (Item item in player.inventory) + { + if (item.IsAir) + continue; + + if (item.Calamity().AppliedEnchantment.HasValue && item.Calamity().AppliedEnchantment.Value.ID == 600) + { + // Initialize the exhaustion if it is currently not defined. + if (item.Calamity().DischargeEnchantExhaustion <= 0f) + item.Calamity().DischargeEnchantExhaustion = CalamityGlobalItem.DischargeEnchantExhaustionCap; + + // Slowly recharge the weapon over time. This is depleted when the item is actaully used. + else if (item.Calamity().DischargeEnchantExhaustion < CalamityGlobalItem.DischargeEnchantExhaustionCap) + item.Calamity().DischargeEnchantExhaustion++; + } + else + item.Calamity().DischargeEnchantExhaustion = 0f; + } + + if (!heldItem.Calamity().AppliedEnchantment.HasValue || heldItem.Calamity().AppliedEnchantment.Value.HoldEffect is null) + return; + + heldItem.Calamity().AppliedEnchantment.Value.HoldEffect(player); + + // Weak brimstone flame hold curse effect. + if (modPlayer.flamingItemEnchant) + player.AddBuff(ModContent.BuffType(), 10); + } + #endregion + #region Max Life And Mana Effects private static void MaxLifeAndManaEffects(Player player, CalamityPlayer modPlayer, Mod mod) { diff --git a/CalamityLists.cs b/CalamityLists.cs index 3acec83e67..20c225f816 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -355,7 +355,8 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType() + ProjectileType(), + ProjectileType() }; rangedProjectileExceptionList = new List() @@ -427,6 +428,7 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), diff --git a/CalamityMod.cs b/CalamityMod.cs index 5589ef2ecf..af8b0b6a10 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -42,6 +42,7 @@ using CalamityMod.Schematics; using CalamityMod.Skies; using CalamityMod.TileEntities; using CalamityMod.UI; +using CalamityMod.UI.CalamitasEnchants; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -187,6 +188,7 @@ namespace CalamityMod BossHealthBarManager.Load(this); DraedonStructures.Load(); CalamityLists.LoadLists(); + EnchantmentManager.LoadAllEnchantments(); SetupVanillaDR(); SetupBossKillTimes(); SetupBossVelocityScalingValues(); @@ -325,6 +327,7 @@ namespace CalamityMod bossVelocityDamageScaleValues?.Clear(); bossVelocityDamageScaleValues = null; + EnchantmentManager.UnloadAllEnchantments(); CalamityLists.UnloadLists(); NPCStats.Unload(); @@ -552,7 +555,7 @@ namespace CalamityMod { ModContent.NPCType(), 7200 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 1200 }, - { ModContent.NPCType(), 11400 }, + { ModContent.NPCType(), 13200 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 10800 }, @@ -921,6 +924,13 @@ namespace CalamityMod return true; }, InterfaceScaleType.None)); + // Calamitas Enchantment UI + layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Calamitas Enchantment", () => + { + CalamitasEnchantUI.Draw(Main.spriteBatch); + return true; + }, InterfaceScaleType.None)); + // Popup GUIs. layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Popup GUIs", () => { diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 1e4fad2bf1..7993b3bcd4 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Effects public static Effect LightDistortionShader; public static Effect PhaseslayerRipShader; public static Effect FadedUVMapStreakShader; + public static Effect FadingSolidTrailShader; public static Effect ScarletDevilShader; public static Effect BordernadoFireShader; public static Effect PrismCrystalShader; @@ -34,6 +35,7 @@ namespace CalamityMod.Effects BordernadoFireShader = CalamityMod.Instance.GetEffect("Effects/BordernadoFire"); PrismCrystalShader = CalamityMod.Instance.GetEffect("Effects/PrismCrystalStreak"); FadedUVMapStreakShader = CalamityMod.Instance.GetEffect("Effects/FadedUVMapStreak"); + FadingSolidTrailShader = CalamityMod.Instance.GetEffect("Effects/FadingSolidTrail"); SCalShieldShader = CalamityMod.Instance.GetEffect("Effects/SupremeShieldShader"); Filters.Scene["CalamityMod:Astral"] = new Filter(new AstralScreenShaderData(new Ref(AstralFogShader), "AstralPass").UseColor(0.18f, 0.08f, 0.24f), EffectPriority.VeryHigh); @@ -46,6 +48,7 @@ namespace CalamityMod.Effects GameShaders.Misc["CalamityMod:LightDistortion"] = new MiscShaderData(new Ref(LightDistortionShader), "DistortionPass"); GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"] = new MiscShaderData(new Ref(PhaseslayerRipShader), "TrailPass"); GameShaders.Misc["CalamityMod:TrailStreak"] = new MiscShaderData(new Ref(FadedUVMapStreakShader), "TrailPass"); + GameShaders.Misc["CalamityMod:FadingSolidTrail"] = new MiscShaderData(new Ref(FadingSolidTrailShader), "TrailPass"); GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"] = new MiscShaderData(new Ref(ScarletDevilShader), "TrailPass"); GameShaders.Misc["CalamityMod:Bordernado"] = new MiscShaderData(new Ref(BordernadoFireShader), "TrailPass"); GameShaders.Misc["CalamityMod:PrismaticStreak"] = new MiscShaderData(new Ref(PrismCrystalShader), "TrailPass"); diff --git a/Effects/FadedUVMapStreak.xnb b/Effects/FadedUVMapStreak.xnb index 45b95d5d3f..fbc7a110ec 100644 Binary files a/Effects/FadedUVMapStreak.xnb and b/Effects/FadedUVMapStreak.xnb differ diff --git a/Effects/FadingSolidTrail.fx b/Effects/FadingSolidTrail.fx new file mode 100644 index 0000000000..5b8427dcff --- /dev/null +++ b/Effects/FadingSolidTrail.fx @@ -0,0 +1,66 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; +float shouldFlip; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput)0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// The X coordinate is the trail completion, the Y coordinate is the same as any other. +// This is simply how the primitive TextCoord is layed out in the C# code. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + if (shouldFlip == 1) + coords.y = 1 - coords.y; + + // Read the fade map as a streak. + float4 fadeMapColor = tex2D(uImage1, coords); + float opacity = fadeMapColor.r; + return color * opacity; +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/FadingSolidTrail.xnb b/Effects/FadingSolidTrail.xnb new file mode 100644 index 0000000000..0d83a614e8 Binary files /dev/null and b/Effects/FadingSolidTrail.xnb differ diff --git a/ExtraTextures/BladeTrailUVMap.png b/ExtraTextures/BladeTrailUVMap.png new file mode 100644 index 0000000000..29e4cdac42 Binary files /dev/null and b/ExtraTextures/BladeTrailUVMap.png differ diff --git a/ExtraTextures/Particles/Fire.png b/ExtraTextures/Particles/Fire.png new file mode 100644 index 0000000000..cc76a599b3 Binary files /dev/null and b/ExtraTextures/Particles/Fire.png differ 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/ExtraTextures/TaintedArm.png b/ExtraTextures/TaintedArm.png new file mode 100644 index 0000000000..f8796f05e7 Binary files /dev/null and b/ExtraTextures/TaintedArm.png differ diff --git a/ExtraTextures/TaintedForearm.png b/ExtraTextures/TaintedForearm.png new file mode 100644 index 0000000000..09355c363c Binary files /dev/null and b/ExtraTextures/TaintedForearm.png differ diff --git a/ExtraTextures/TaintedHand.png b/ExtraTextures/TaintedHand.png new file mode 100644 index 0000000000..89e494b14c Binary files /dev/null and b/ExtraTextures/TaintedHand.png differ diff --git a/ExtraTextures/TaintedHand2.png b/ExtraTextures/TaintedHand2.png new file mode 100644 index 0000000000..7050006ac8 Binary files /dev/null and b/ExtraTextures/TaintedHand2.png differ diff --git a/ExtraTextures/UI/CalamitasCurseBackground.png b/ExtraTextures/UI/CalamitasCurseBackground.png new file mode 100644 index 0000000000..29555271c1 Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseBackground.png differ diff --git a/ExtraTextures/UI/CalamitasCurseItemSlot.png b/ExtraTextures/UI/CalamitasCurseItemSlot.png new file mode 100644 index 0000000000..59e813980f Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseItemSlot.png differ diff --git a/ExtraTextures/UI/CalamitasCurseUI_ArrowDown.png b/ExtraTextures/UI/CalamitasCurseUI_ArrowDown.png new file mode 100644 index 0000000000..055426f728 Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseUI_ArrowDown.png differ diff --git a/ExtraTextures/UI/CalamitasCurseUI_ArrowDownClicked.png b/ExtraTextures/UI/CalamitasCurseUI_ArrowDownClicked.png new file mode 100644 index 0000000000..21aa985d34 Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseUI_ArrowDownClicked.png differ diff --git a/ExtraTextures/UI/CalamitasCurseUI_ArrowDownHovered.png b/ExtraTextures/UI/CalamitasCurseUI_ArrowDownHovered.png new file mode 100644 index 0000000000..56352fe81f Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseUI_ArrowDownHovered.png differ diff --git a/ExtraTextures/UI/CalamitasCurseUI_ArrowUp.png b/ExtraTextures/UI/CalamitasCurseUI_ArrowUp.png new file mode 100644 index 0000000000..7b06ca7dda Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseUI_ArrowUp.png differ diff --git a/ExtraTextures/UI/CalamitasCurseUI_ArrowUpClicked.png b/ExtraTextures/UI/CalamitasCurseUI_ArrowUpClicked.png new file mode 100644 index 0000000000..fc8bc6b539 Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseUI_ArrowUpClicked.png differ diff --git a/ExtraTextures/UI/CalamitasCurseUI_ArrowUpHovered.png b/ExtraTextures/UI/CalamitasCurseUI_ArrowUpHovered.png new file mode 100644 index 0000000000..6894e585fc Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseUI_ArrowUpHovered.png differ diff --git a/ExtraTextures/UI/CalamitasCurseUI_Button.png b/ExtraTextures/UI/CalamitasCurseUI_Button.png new file mode 100644 index 0000000000..42694b1b18 Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseUI_Button.png differ diff --git a/ExtraTextures/UI/CalamitasCurseUI_ButtonClicked.png b/ExtraTextures/UI/CalamitasCurseUI_ButtonClicked.png new file mode 100644 index 0000000000..c817343035 Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseUI_ButtonClicked.png differ diff --git a/ExtraTextures/UI/CalamitasCurseUI_ButtonHovered.png b/ExtraTextures/UI/CalamitasCurseUI_ButtonHovered.png new file mode 100644 index 0000000000..3b9ad755f1 Binary files /dev/null and b/ExtraTextures/UI/CalamitasCurseUI_ButtonHovered.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Aflame.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Aflame.png new file mode 100644 index 0000000000..8d8c0b27ec Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Aflame.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Bloodthirsty.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Bloodthirsty.png new file mode 100644 index 0000000000..583179b633 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Bloodthirsty.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Capricious.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Capricious.png new file mode 100644 index 0000000000..9c75e5ba01 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Capricious.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Ephemeral.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Ephemeral.png new file mode 100644 index 0000000000..5d8f8666be Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Ephemeral.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Erratic.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Erratic.png new file mode 100644 index 0000000000..9d114ac4af Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Erratic.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Evasive.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Evasive.png new file mode 100644 index 0000000000..3969952ddc Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Evasive.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Evocative.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Evocative.png new file mode 100644 index 0000000000..588a10e3b0 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Evocative.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Exhumed.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Exhumed.png new file mode 100644 index 0000000000..584bd62881 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Exhumed.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Hellbound.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Hellbound.png new file mode 100644 index 0000000000..96b2a87a02 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Hellbound.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Incisive.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Incisive.png new file mode 100644 index 0000000000..fe9459ec61 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Incisive.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Indignant.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Indignant.png new file mode 100644 index 0000000000..526223131e Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Indignant.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Lecherous.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Lecherous.png new file mode 100644 index 0000000000..fcbbe480bb Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Lecherous.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Oblatory.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Oblatory.png new file mode 100644 index 0000000000..f4d86bb62f Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Oblatory.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Obstinate.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Obstinate.png new file mode 100644 index 0000000000..41a740b387 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Obstinate.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Persecuted.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Persecuted.png new file mode 100644 index 0000000000..d4999cd4ad Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Persecuted.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Polluted.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Polluted.png new file mode 100644 index 0000000000..4edccb5b2b Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Polluted.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Relentless.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Relentless.png new file mode 100644 index 0000000000..df19b8d4c1 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Relentless.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Resentful.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Resentful.png new file mode 100644 index 0000000000..6259357bb1 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Resentful.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Splintered.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Splintered.png new file mode 100644 index 0000000000..0f75aff9d7 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Splintered.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Tainted.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Tainted.png new file mode 100644 index 0000000000..c3b9d97ec5 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Tainted.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Traitorous.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Traitorous.png new file mode 100644 index 0000000000..9a7f8c7cec Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Traitorous.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Vindictive.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Vindictive.png new file mode 100644 index 0000000000..3a768a4e8e Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Vindictive.png differ diff --git a/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Withered.png b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Withered.png new file mode 100644 index 0000000000..fd20048613 Binary files /dev/null and b/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Withered.png differ diff --git a/ExtraTextures/UI/ModeIndicatorArea.png b/ExtraTextures/UI/ModeIndicatorArea.png index 701089c3cc..508fe00039 100644 Binary files a/ExtraTextures/UI/ModeIndicatorArea.png and b/ExtraTextures/UI/ModeIndicatorArea.png differ diff --git a/ExtraTextures/UI/ModeIndicatorArma.png b/ExtraTextures/UI/ModeIndicatorArma.png index d5e6ea594e..619f29b4a2 100644 Binary files a/ExtraTextures/UI/ModeIndicatorArma.png and b/ExtraTextures/UI/ModeIndicatorArma.png differ diff --git a/ExtraTextures/UI/ModeIndicatorDeath.png b/ExtraTextures/UI/ModeIndicatorDeath.png index 5cb843a4e0..cdf63aea54 100644 Binary files a/ExtraTextures/UI/ModeIndicatorDeath.png and b/ExtraTextures/UI/ModeIndicatorDeath.png differ diff --git a/ExtraTextures/UI/ModeIndicatorMalice.png b/ExtraTextures/UI/ModeIndicatorMalice.png new file mode 100644 index 0000000000..c19e5c029e Binary files /dev/null and b/ExtraTextures/UI/ModeIndicatorMalice.png differ diff --git a/ExtraTextures/UI/ModeIndicatorRev.png b/ExtraTextures/UI/ModeIndicatorRev.png index b1209d63f8..6086ff88b7 100644 Binary files a/ExtraTextures/UI/ModeIndicatorRev.png and b/ExtraTextures/UI/ModeIndicatorRev.png differ diff --git a/ExtraTextures/UI/ModeIndicatorRune.png b/ExtraTextures/UI/ModeIndicatorRune.png deleted file mode 100644 index 51a2ed08d5..0000000000 Binary files a/ExtraTextures/UI/ModeIndicatorRune.png and /dev/null differ diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index c19082b208..1c179f279c 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -1,6 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.NPCs; +using CalamityMod.Projectiles; using CalamityMod.Tiles.DraedonStructures; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -123,6 +124,7 @@ namespace CalamityMod.ILEditing DisableDemonAltarGeneration(); DisableTeleportersDuringBossFights(); FixSplittingWormBannerDrops(); + IncorporateMinionExplodingCountdown(); UseCoolFireCursorEffect(); MakeMouseHoverItemsSupportAnimations(); } @@ -453,6 +455,25 @@ namespace CalamityMod.ILEditing }; } + private static void IncorporateMinionExplodingCountdown() + { + On.Terraria.Projectile.NewProjectile_float_float_float_float_int_int_float_int_float_float += (orig, x, y, xSpeed, ySpeed, type, damage, knockback, owner, ai0, ai1) => + { + // This is unfortunately not something that can be done via SetDefaults since owner is set + // after that method is called. Doing it directly when the projectile is spawned appears to be the only reasonable way. + int proj = orig(x, y, xSpeed, ySpeed, type, damage, knockback, owner, ai0, ai1); + Projectile projectile = Main.projectile[proj]; + if (projectile.minion) + { + Player player = Main.player[projectile.owner]; + CalamityPlayerMiscEffects.EnchantHeldItemEffects(player, player.Calamity(), player.ActiveItem()); + if (player.Calamity().explosiveMinionsEnchant) + projectile.Calamity().ExplosiveEnchantCountdown = CalamityGlobalProjectile.ExplosiveEnchantTime; + } + return proj; + }; + } + private static void MakeMouseHoverItemsSupportAnimations() { IL.Terraria.Main.DrawInterface_40_InteractItemIcon += (il) => @@ -482,8 +503,8 @@ namespace CalamityMod.ILEditing #endregion - #region IL Editing Injected/Hooked Functions - private static void BossRushLifeBytes(On.Terraria.Main.orig_InitLifeBytes orig) + #region IL Editing Injected/Hooked Functions + private static void BossRushLifeBytes(On.Terraria.Main.orig_InitLifeBytes orig) { orig(); foreach (int npcType in NeedsFourLifeBytes) @@ -591,7 +612,7 @@ namespace CalamityMod.ILEditing Main.spriteBatch.Draw(Main.cursorTextures[cursorIndex], drawPosition, null, desaturatedCursorColor, 0f, Vector2.Zero, Main.cursorScale, SpriteEffects.None, 0f); Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.UIScaleMatrix); GameShaders.Misc["CalamityMod:FireMouse"].UseColor(Color.Red); GameShaders.Misc["CalamityMod:FireMouse"].UseSecondaryColor(Color.Lerp(Color.Red, Color.Orange, 0.75f)); GameShaders.Misc["CalamityMod:FireMouse"].Apply(); diff --git a/Items/Accessories/AmbrosialAmpoule.cs b/Items/Accessories/AmbrosialAmpoule.cs index 4286e66c63..ac477ff3f0 100644 --- a/Items/Accessories/AmbrosialAmpoule.cs +++ b/Items/Accessories/AmbrosialAmpoule.cs @@ -51,6 +51,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.beeResist = true; modPlayer.aAmpoule = true; + modPlayer.rOoze = true; } public override void AddRecipes() diff --git a/Items/Accessories/RadiantOoze.cs b/Items/Accessories/RadiantOoze.cs index d25f436569..4828b840ba 100644 --- a/Items/Accessories/RadiantOoze.cs +++ b/Items/Accessories/RadiantOoze.cs @@ -25,11 +25,6 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.Calamity().rOoze = true; - if (!Main.dayTime) - { - Lighting.AddLight((int)(player.position.X + (float)(player.width / 2)) / 16, (int)(player.position.Y + (float)(player.height / 2)) / 16, 1f, 1f, 0.6f); - player.lifeRegen += 4; - } } public override void AddRecipes() diff --git a/Items/Accessories/ShatteredCommunity.cs b/Items/Accessories/ShatteredCommunity.cs index f26df095ed..731ab8fe33 100644 --- a/Items/Accessories/ShatteredCommunity.cs +++ b/Items/Accessories/ShatteredCommunity.cs @@ -238,30 +238,5 @@ namespace CalamityMod.Items.Accessories level = reader.ReadInt32(); totalRageDamage = reader.ReadInt64(); } - - public override void AddRecipes() - { - ModRecipe r = new ShatteredCommunityRecipe(mod); - r.SetResult(this); - r.AddIngredient(ModContent.ItemType()); - r.AddIngredient(ModContent.ItemType()); - r.AddIngredient(ModContent.ItemType(), 120); - r.AddRecipe(); - } - - // The Shattered Community can only be crafted with a full-power Community. - // That is, in a world where all relevant bosses have been defeated. - private class ShatteredCommunityRecipe : ModRecipe - { - public ShatteredCommunityRecipe(Mod mod) : base(mod) { } - - public override bool RecipeAvailable() - { - bool vanillaBosses = NPC.downedSlimeKing && NPC.downedBoss1 && NPC.downedBoss2 && NPC.downedQueenBee && NPC.downedBoss3 && Main.hardMode; - vanillaBosses &= NPC.downedMechBossAny && NPC.downedPlantBoss && NPC.downedGolemBoss && NPC.downedFishron && NPC.downedAncientCultist && NPC.downedMoonlord; - bool calamityBosses = CalamityWorld.downedProvidence && CalamityWorld.downedDoG && CalamityWorld.downedYharon; - return vanillaBosses && calamityBosses; - } - } } } diff --git a/Items/Accessories/Sponge.cs b/Items/Accessories/Sponge.cs index 107bcab7ec..c5d984bb12 100644 --- a/Items/Accessories/Sponge.cs +++ b/Items/Accessories/Sponge.cs @@ -78,6 +78,7 @@ namespace CalamityMod.Items.Accessories modPlayer.seaShell = true; modPlayer.absorber = true; modPlayer.aAmpoule = true; + modPlayer.rOoze = true; player.statManaMax2 += 20; } 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..4f08d4e2d2 Binary files /dev/null and b/Items/BrimstoneLocus.png differ diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 88221b654d..babd4bca52 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -6,8 +6,10 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Potions; using CalamityMod.Items.Weapons.Melee; 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; @@ -15,8 +17,10 @@ using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.UI; +using CalamityMod.UI.CalamitasEnchants; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; @@ -50,10 +54,26 @@ namespace CalamityMod.Items return float.IsNaN(ratio) || float.IsInfinity(ratio) ? 0f : MathHelper.Clamp(ratio, 0f, 1f); } } - #endregion + #endregion - // Miscellaneous stuff - public CalamityRarity customRarity = CalamityRarity.NoEffect; + #region Enchantment Variables + public Enchantment? AppliedEnchantment = null; + public float DischargeEnchantExhaustion = 0; + public float DischargeExhaustionRatio + { + get + { + float ratio = DischargeEnchantExhaustion / DischargeEnchantExhaustionCap; + return float.IsNaN(ratio) || float.IsInfinity(ratio) ? 0f : MathHelper.Clamp(ratio, 0f, 1f); + } + } + public const float DischargeEnchantExhaustionCap = 1600f; + public const float DischargeEnchantMinDamageFactor = 0.77f; + public const float DischargeEnchantMaxDamageFactor = 1.26f; + #endregion + + // Miscellaneous stuff + public CalamityRarity customRarity = CalamityRarity.NoEffect; public int timesUsed = 0; public int reforgeTier = 0; public bool donorItem = false; @@ -83,6 +103,7 @@ namespace CalamityMod.Items { CalamityGlobalItem myClone = (CalamityGlobalItem)base.Clone(item, itemClone); myClone.StealthGenBonus = StealthGenBonus; + myClone.DischargeEnchantExhaustion = DischargeEnchantExhaustion; myClone.Charge = Charge; return myClone; } @@ -109,7 +130,10 @@ namespace CalamityMod.Items if (item.type == ItemID.PirateMap || item.type == ItemID.SnowGlobe) item.maxStack = 20; - if (item.type >= ItemID.GreenSolution && item.type <= ItemID.RedSolution) + if (item.type == ItemID.CelestialSigil) + item.maxStack = 1; + + if (item.type >= ItemID.GreenSolution && item.type <= ItemID.RedSolution) item.value = Item.buyPrice(0, 0, 5, 0); if (CalamityLists.useTurnList?.Contains(item.type) ?? false) @@ -236,6 +260,7 @@ namespace CalamityMod.Items public override bool Shoot(Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { CalamityPlayer modPlayer = player.Calamity(); + if (rogue) { speedX *= modPlayer.throwingVelocity; @@ -476,10 +501,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; } @@ -492,8 +517,10 @@ namespace CalamityMod.Items ["timesUsed"] = timesUsed, ["rarity"] = (int)customRarity, ["charge"] = Charge, - ["reforgeTier"] = reforgeTier - }; + ["reforgeTier"] = reforgeTier, + ["enchantmentID"] = AppliedEnchantment.HasValue ? AppliedEnchantment.Value.ID : 0, + ["DischargeEnchantExhaustion"] = DischargeEnchantExhaustion + }; } public override void Load(Item item, TagCompound tag) @@ -508,8 +535,16 @@ namespace CalamityMod.Items else Charge = tag.GetFloat("charge"); + DischargeEnchantExhaustion = tag.GetFloat("DischargeEnchantExhaustion"); reforgeTier = tag.GetInt("reforgeTimer"); - } + Enchantment? savedEnchantment = EnchantmentManager.FindByID(tag.GetInt("enchantmentID")); + if (savedEnchantment.HasValue) + { + AppliedEnchantment = savedEnchantment.Value; + bool hasCreationEffect = AppliedEnchantment.Value.CreationEffect != null; + item.Calamity().AppliedEnchantment.Value.CreationEffect?.Invoke(item); + } + } public override void LoadLegacy(Item item, BinaryReader reader) { @@ -540,7 +575,9 @@ namespace CalamityMod.Items writer.Write(timesUsed); writer.Write(Charge); writer.Write(reforgeTier); - } + writer.Write(AppliedEnchantment.HasValue ? AppliedEnchantment.Value.ID : 0); + writer.Write(DischargeEnchantExhaustion); + } public override void NetReceive(Item item, BinaryReader reader) { @@ -551,7 +588,17 @@ namespace CalamityMod.Items timesUsed = reader.ReadInt32(); Charge = reader.ReadSingle(); reforgeTier = reader.ReadInt32(); - } + + Enchantment? savedEnchantment = EnchantmentManager.FindByID(reader.ReadInt32()); + if (savedEnchantment.HasValue) + { + AppliedEnchantment = savedEnchantment.Value; + bool hasCreationEffect = AppliedEnchantment.Value.CreationEffect != null; + if (hasCreationEffect) + item.Calamity().AppliedEnchantment.Value.CreationEffect(item); + } + DischargeEnchantExhaustion = reader.ReadSingle(); + } #endregion #region Pickup Item Changes @@ -597,7 +644,7 @@ namespace CalamityMod.Items NetMessage.SendData(MessageID.MoonlordCountdown, -1, -1, null, NPC.MoonLordCountdown); } - return base.UseItem(item, player); + return base.UseItem(item, player); } public override bool AltFunctionUse(Item item, Player player) @@ -706,7 +753,22 @@ namespace CalamityMod.Items if (PopupGUIManager.AnyGUIsActive) return false; - if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && + if (player.Calamity().cursedSummonsEnchant && NPC.CountNPCS(ModContent.NPCType()) < 2) + { + Point spawnPosition = Main.MouseWorld.ToPoint(); + NPC.NewNPC(spawnPosition.X, spawnPosition.Y, ModContent.NPCType(), Target: player.whoAmI); + Main.PlaySound(SoundID.DD2_DarkMageSummonSkeleton, Main.MouseWorld); + } + + bool belowHalfMana = player.statMana < player.statManaMax2 * 0.5f; + if (player.Calamity().manaMonsterEnchant && Main.rand.NextBool(12) && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && belowHalfMana) + { + int damage = (int)(165000 * player.MagicDamage()); + Vector2 shootVelocity = player.SafeDirectionTo(Main.MouseWorld, -Vector2.UnitY).RotatedByRandom(0.07f) * Main.rand.NextFloat(4f, 5f); + Projectile.NewProjectile(player.Center + shootVelocity, shootVelocity, ModContent.ProjectileType(), damage, 0f, player.whoAmI); + } + + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && (item.damage > 0 || item.ammo != AmmoID.None)) { return false; // Don't use weapons if you're charging with a spear @@ -728,6 +790,15 @@ namespace CalamityMod.Items if (modPlayer.profanedCrystalBuffs && item.pick == 0 && item.axe == 0 && item.hammer == 0 && item.autoReuse && (modItem.rogue || item.magic || item.ranged || item.melee)) return player.altFunctionUse == 0 ? ProfanedSoulCrystal.TransformItemUsage(item, player) : AltFunctionUse(item, player); + // Exhaust the weapon if it has the necessary enchant. + if (!item.IsAir && modPlayer.dischargingItemEnchant) + { + float exhaustionCost = item.useTime * 2.25f; + if (exhaustionCost < 10f) + exhaustionCost = 10f; + DischargeEnchantExhaustion = MathHelper.Clamp(DischargeEnchantExhaustion - exhaustionCost, 0.001f, DischargeEnchantExhaustionCap); + } + // Check for sufficient charge if this item uses charge. if (item.type >= ItemID.Count && modItem.UsesCharge) { @@ -837,7 +908,11 @@ namespace CalamityMod.Items // Summon weapons specifically do not have their damage affected by charge. They still require charge to function however. CalamityGlobalItem modItem = item.Calamity(); - if (!item.summon && (modItem?.UsesCharge ?? false)) + + if (!item.summon && modItem.DischargeEnchantExhaustion > 0f) + mult *= DischargeEnchantmentDamageFormula(); + + if (!item.summon && (modItem?.UsesCharge ?? false)) { // At exactly zero charge, do not perform any multiplication. // This makes charge-using weapons show up at full damage when previewed in crafting, Recipe Browser, etc. @@ -847,9 +922,20 @@ namespace CalamityMod.Items } } - // This formula gives a slightly higher value than 1.0 above 85% charge, and a slightly lower value than 0.0 at 0% charge. - // Specifically, it gives 0.0 or less at 0.36% charge or lower. This is fine because the result is immediately clamped. - internal float ChargeDamageFormula() + internal float DischargeEnchantmentDamageFormula() + { + // This exponential has the properties of beginning at 0 and ending at 1, yet also has their signature rising curve. + // It is therefore perfect for a potential interpolant. + float interpolant = (float)Math.Pow(2D, DischargeExhaustionRatio) - 1f; + + // No further smoothening is required in the form of a Smoothstep remap. + // A linear interpolation works fine; the exponential already has the desired curve shape. + return MathHelper.Lerp(DischargeEnchantMinDamageFactor, DischargeEnchantMaxDamageFactor, interpolant); + } + + // This formula gives a slightly higher value than 1.0 above 85% charge, and a slightly lower value than 0.0 at 0% charge. + // Specifically, it gives 0.0 or less at 0.36% charge or lower. This is fine because the result is immediately clamped. + internal float ChargeDamageFormula() { float x = MathHelper.Clamp(ChargeRatio, 0f, 1f); float y = 1.087f - 0.08f / (x + 0.07f); @@ -1633,6 +1719,48 @@ namespace CalamityMod.Items } #endregion + #region Inventory Drawing + internal static ChargingEnergyParticleSet EnchantmentEnergyParticles = new ChargingEnergyParticleSet(-1, 2, Color.DarkViolet, Color.White, 0.04f, 24f); + + internal static void UpdateAllParticleSets() + { + EnchantmentEnergyParticles.Update(); + } + + 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() : 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; + + // 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 += frame.Size() * 0.25f; + 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/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 43f918915b..18e8914eb6 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -10,6 +10,7 @@ using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; using System.Linq; @@ -17,6 +18,7 @@ using System.Text; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.UI.Chat; namespace CalamityMod.Items { @@ -41,6 +43,10 @@ namespace CalamityMod.Items // This is placed between vanilla tooltip edits and mod mechanics because it can apply to vanilla items. StealthGenAccessoryTooltip(item, tooltips); + // If an item has an enchantment, show its prefix in the first tooltip line and append its description to the + // tooltip list. + EnchantmentTooltips(item, tooltips); + // Everything below this line can only apply to modded items. If the item is vanilla, stop here for efficiency. if (item.type < ItemID.Count) return; @@ -227,6 +233,19 @@ namespace CalamityMod.Items } #endregion + #region Enchantment Tooltips + private void EnchantmentTooltips(Item item, IList tooltips) + { + if (!item.IsAir && AppliedEnchantment.HasValue) + { + tooltips[0].text = $"{AppliedEnchantment.Value.Name} {tooltips[0].text}"; + + TooltipLine descriptionLine = new TooltipLine(mod, "Enchantment", CalamityUtils.ColorMessage(AppliedEnchantment.Value.Description, Color.DarkRed)); + tooltips.Add(descriptionLine); + } + } + #endregion + #region Vanilla Item Tooltip Modification private void ModifyVanillaTooltips(Item item, IList tooltips) { @@ -964,6 +983,39 @@ namespace CalamityMod.Items } #endregion + #region Enchanted Rarity Text Drawing + public override bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset) + { + // Special enchantment line color. + if (line.Name == "ItemName" && line.mod == "Terraria" && item.IsEnchanted()) + { + Color rarityColor = line.overrideColor ?? line.color; + Vector2 basePosition = new Vector2(line.X, line.Y); + + float backInterpolant = (float)Math.Pow(Main.GlobalTime * 0.81f % 1f, 1.5f); + Vector2 backScale = line.baseScale * MathHelper.Lerp(1f, 1.2f, backInterpolant); + Color backColor = Color.Lerp(rarityColor, Color.DarkRed, backInterpolant) * (float)Math.Pow(1f - backInterpolant, 0.46f); + Vector2 backPosition = basePosition - new Vector2(1f, 0.1f) * backInterpolant * 10f; + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive); + + // Draw the back text as an ominous pulse. + for (int i = 0; i < 2; i++) + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.font, line.text, backPosition, backColor, line.rotation, line.origin, backScale, line.maxWidth, line.spread); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(); + + // Draw the front text as usual. + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.font, line.text, basePosition, rarityColor, line.rotation, line.origin, line.baseScale, line.maxWidth, line.spread); + + return false; + } + return true; + } + #endregion + #region Fargo Biome Fountain Tooltip private void FargoFountainTooltip(Item item, IList tooltips) { diff --git a/Items/DifficultyItems/Malice.cs b/Items/DifficultyItems/Malice.cs index 998250226f..874febecbf 100644 --- a/Items/DifficultyItems/Malice.cs +++ b/Items/DifficultyItems/Malice.cs @@ -3,6 +3,7 @@ using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -16,6 +17,7 @@ namespace CalamityMod.Items.DifficultyItems Tooltip.SetDefault("Enrages every boss and allows them to drop special items.\n" + "Nurse no longer heals while a boss is alive.\n" + "Effect can be toggled on and off."); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 8)); } public override void SetDefaults() @@ -27,6 +29,7 @@ namespace CalamityMod.Items.DifficultyItems item.useTime = 45; item.useStyle = ItemUseStyleID.HoldingUp; item.UseSound = SoundID.Item119; + item.noUseGraphic = true; item.consumable = false; } diff --git a/Items/DifficultyItems/Malice.png b/Items/DifficultyItems/Malice.png index 493a9b001c..fa448647be 100644 Binary files a/Items/DifficultyItems/Malice.png and b/Items/DifficultyItems/Malice.png differ diff --git a/Items/Weapons/Magic/RainbowPartyCannon.cs b/Items/Weapons/Magic/RainbowPartyCannon.cs index 94188df883..a346414cf1 100644 --- a/Items/Weapons/Magic/RainbowPartyCannon.cs +++ b/Items/Weapons/Magic/RainbowPartyCannon.cs @@ -49,12 +49,13 @@ namespace CalamityMod.Items.Weapons.Magic item.shoot = ModContent.ProjectileType(); item.channel = true; item.shootSpeed = 20f; + item.Calamity().devItem = true; } public override void ModifyTooltips(List tooltips) { var tt2 = tooltips.FirstOrDefault(x => x.Name == "Tooltip0" && x.mod == "Terraria"); - tt2.overrideColor = new Color(MathHelper.Lerp(156f, 255f, Main.DiscoR / 256f), 108f, 251f); + tt2.overrideColor = new Color((int)MathHelper.Lerp(156f, 255f, Main.DiscoR / 256f), 108, 251); } public override void AddRecipes() diff --git a/Items/Weapons/Melee/Murasama.cs b/Items/Weapons/Melee/Murasama.cs index 28ea5cf715..30c4f8561a 100644 --- a/Items/Weapons/Melee/Murasama.cs +++ b/Items/Weapons/Melee/Murasama.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee Tooltip.SetDefault("There will be blood!\n" + "ID and power-level locked\n" + "Prove your strength or have the correct user ID to wield this sword"); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 13)); } public override void SetDefaults() diff --git a/Items/Weapons/Ranged/BulletFilledShotgun.cs b/Items/Weapons/Ranged/BulletFilledShotgun.cs index 7b38b8dc0d..0dcb7bf48a 100644 --- a/Items/Weapons/Ranged/BulletFilledShotgun.cs +++ b/Items/Weapons/Ranged/BulletFilledShotgun.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Bullet-Filled Shotgun"); Tooltip.SetDefault("Fires a massive spread of bouncing bullets\n" + - "Consumes five ammo per fire\n" + + "Consumes five bullets per-use\n" + "Aim? What's that?"); } public override void SetDefaults() diff --git a/Items/Weapons/Summon/ExhumedVigilance.cs b/Items/Weapons/Summon/ExhumedVigilance.cs new file mode 100644 index 0000000000..185a2ccd9d --- /dev/null +++ b/Items/Weapons/Summon/ExhumedVigilance.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 ExhumedVigilance : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Exhumed Vigilance"); + 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 = 1666; + 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/ExhumedVigilance.png b/Items/Weapons/Summon/ExhumedVigilance.png new file mode 100644 index 0000000000..96d3b0caf3 Binary files /dev/null and b/Items/Weapons/Summon/ExhumedVigilance.png differ diff --git a/Items/Weapons/Summon/StaffoftheMechworm2.cs b/Items/Weapons/Summon/StaffoftheMechworm2.cs new file mode 100644 index 0000000000..54a05bfb70 --- /dev/null +++ b/Items/Weapons/Summon/StaffoftheMechworm2.cs @@ -0,0 +1,51 @@ +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class StaffoftheMechworm2 : ModItem + { + // This is unfinished atm. + public override bool Autoload(ref string name) => false; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Staff of the Mechworm (But Exhumed!)"); + Tooltip.SetDefault("Summons a sepulcher to fight for you\n" + + "While the sepulcher is active brimstone hearts will begin to appear and orbit you\n" + + "The sepulcher will attempt to attack you more and more frequently depending on how many hearts are present\n" + + "The sepulcher takes up 4 minion slots"); + } + + public override void SetDefaults() + { + item.damage = 666; + item.mana = 15; + item.width = 58; + item.height = 58; + item.useTime = item.useAnimation = 12; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 2f; + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.UseSound = SoundID.DD2_BetsySummon; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(Main.MouseWorld, -Vector2.UnitY * 5f, type, damage, knockBack, player.whoAmI); + return false; + } + } +} diff --git a/Items/Weapons/Summon/StaffoftheMechworm2.png b/Items/Weapons/Summon/StaffoftheMechworm2.png new file mode 100644 index 0000000000..ffcc7066c0 Binary files /dev/null and b/Items/Weapons/Summon/StaffoftheMechworm2.png differ diff --git a/Items/Weapons/Summon/UniverseSplitter.cs b/Items/Weapons/Summon/UniverseSplitter.cs index 66c282b95e..10806aa174 100644 --- a/Items/Weapons/Summon/UniverseSplitter.cs +++ b/Items/Weapons/Summon/UniverseSplitter.cs @@ -47,6 +47,7 @@ namespace CalamityMod.Items.Weapons.Summon item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; item.Calamity().customRarity = CalamityRarity.HotPink; + item.Calamity().devItem = true; } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index 96b6129f2f..16aee95c21 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -2,6 +2,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.Items; using CalamityMod.Projectiles; +using CalamityMod.UI.CalamitasEnchants; using CalamityMod.World; using System; using System.Collections.Generic; @@ -1707,6 +1708,11 @@ namespace CalamityMod CalamityLists.MinionsToNotResurrectList.AddRange(secondaryArguments.Select(argument => Convert.ToInt32(argument))); return null; + case "CreateEnchantment": + case "RegisterEnchantment": + EnchantmentManager.ConstructFromModcall(args.Skip(1)); + return null; + default: return new ArgumentException("ERROR: Invalid method name."); } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index b4559428a3..093719ee1f 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -29,6 +29,7 @@ using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Perforator; +using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.PlaguebringerGoliath; using CalamityMod.NPCs.Polterghast; using CalamityMod.NPCs.ProfanedGuardians; @@ -40,6 +41,7 @@ using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SulphurousSea; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.Yharon; +using CalamityMod.Particles; using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; @@ -60,7 +62,6 @@ using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; -using CalamityMod.NPCs.PlagueEnemies; namespace CalamityMod.NPCs { @@ -113,6 +114,9 @@ namespace CalamityMod.NPCs public int shopAlertAnimTimer = 0; public int shopAlertAnimFrame = 0; + // Rage interactions + public bool DoesNotGenerateRage = false; + // NewAI internal const int maxAIMod = 4; public float[] newAI = new float[maxAIMod]; @@ -147,7 +151,7 @@ namespace CalamityMod.NPCs public int wCleave = 0; public int bBlood = 0; public int dFlames = 0; - public int marked = 0; + public int marked = 0; public int irradiated = 0; public int bFlames = 0; public int hFlames = 0; @@ -216,6 +220,9 @@ namespace CalamityMod.NPCs public static int draedonExoMechPrime = -1; public static int adultEidolonWyrmHead = -1; + // Drawing variables. + public FireParticleSet VulnerabilityHexFireDrawer = null; + // Boss Enrage variable for use with the boss health UI. // The logic behind this is as follows: // 1 - For special cases with super-enrages (specifically Yharon/SCal with their arenas), go solely based on whether that enrage is active. That information is most important to the player. @@ -969,7 +976,8 @@ namespace CalamityMod.NPCs ApplyDPSDebuff(pShred, 1500, 300, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(nightwither, 200, 40, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(dFlames, 2500, 500, ref npc.lifeRegen, ref damage); - ApplyDPSDebuff(bBlood, 50, 10, ref npc.lifeRegen, ref damage); + ApplyDPSDebuff(vulnerabilityHex, 44440, 4444, ref npc.lifeRegen, ref damage); + ApplyDPSDebuff(bBlood, 50, 10, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(kamiFlu, 250, 25, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(vulnerabilityHex, 44440, 4444, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(sulphurPoison, 180, 36, ref npc.lifeRegen, ref damage); @@ -1993,7 +2001,9 @@ namespace CalamityMod.NPCs #region Pre AI public override bool PreAI(NPC npc) { - CalamityGlobalTownNPC.SetPatreonTownNPCName(npc, mod); + if (VulnerabilityHexFireDrawer != null) + VulnerabilityHexFireDrawer.Update(); + CalamityGlobalTownNPC.SetPatreonTownNPCName(npc, mod); // Decrement each immune timer if it's greater than 0. for (int i = 0; i < maxPlayerImmunities; i++) @@ -3513,6 +3523,8 @@ namespace CalamityMod.NPCs bBlood--; if (dFlames > 0) dFlames--; + if (vulnerabilityHex > 0) + vulnerabilityHex--; if (marked > 0) marked--; if (irradiated > 0) @@ -4939,6 +4951,24 @@ namespace CalamityMod.NPCs Main.spriteBatch.Draw(Main.npcTexture[npc.type], new Vector2(position9.X - Main.screenPosition.X + npc.width / 2 - Main.npcTexture[npc.type].Width * npc.scale / 2f + vector11.X * npc.scale, position9.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + vector11.Y * npc.scale + num66 + npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alpha15, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } + else + { + if (npc.Calamity().vulnerabilityHex > 0) + { + float compactness = npc.width * 0.6f; + if (compactness < 10f) + compactness = 10f; + float power = npc.height / 100f; + if (power > 2.75f) + power = 2.75f; + if (VulnerabilityHexFireDrawer is null || VulnerabilityHexFireDrawer.LocalTimer >= VulnerabilityHexFireDrawer.SetLifetime) + VulnerabilityHexFireDrawer = new FireParticleSet(npc.Calamity().vulnerabilityHex, 1, Color.Red * 1.25f, Color.Red, compactness, power); + else + VulnerabilityHexFireDrawer.DrawSet(npc.Bottom - Vector2.UnitY * (12f - npc.gfxOffY)); + } + else + VulnerabilityHexFireDrawer = null; + } // Draw a pillar of light and fade the background as an animation when skipping things in the DD2 event. if (npc.type == NPCID.DD2EterniaCrystal) diff --git a/NPCs/Other/BrimstoneOrb.cs b/NPCs/Other/BrimstoneOrb.cs new file mode 100644 index 0000000000..8468cd95e5 --- /dev/null +++ b/NPCs/Other/BrimstoneOrb.cs @@ -0,0 +1,104 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.Other +{ + public class BrimstoneOrb : ModNPC + { + public ref float Time => ref npc.ai[0]; + public Player Owner + { + get + { + if (npc.target >= 255 || npc.target < 0) + npc.TargetClosest(); + return Main.player[npc.target]; + } + } + public override void SetStaticDefaults() => DisplayName.SetDefault("Brimstone Orb"); + + public override void SetDefaults() + { + npc.width = npc.height = 28; + npc.damage = 0; + npc.defense = 0; + npc.lifeMax = 97444; + npc.noGravity = true; + npc.noTileCollide = true; + npc.value = 0f; + npc.HitSound = SoundID.NPCHit5; + npc.DeathSound = SoundID.NPCDeath7; + npc.knockBackResist = 0f; + npc.netAlways = true; + npc.aiStyle = -1; + npc.Calamity().DoesNotGenerateRage = true; + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 97444; + + public override void AI() + { + npc.Opacity = Utils.InverseLerp(0f, 15f, Time, true); + npc.velocity = Vector2.Zero; + + if (Main.myPlayer == npc.target) + { + // Disappear if the player no longer has the enchanted weapon. + if (!Owner.Calamity().lecherousOrbEnchant) + { + npc.active = false; + npc.netUpdate = true; + } + + Vector2 destination = Vector2.Lerp(Owner.Center, Main.MouseWorld, 0.3f); + npc.Center = Vector2.Lerp(npc.Center, destination, 0.035f).MoveTowards(destination, 5f); + if (!npc.WithinRange(destination, 2000f)) + npc.Center = Owner.Center; + + if (npc.Center != destination) + { + npc.netSpam = 0; + npc.netUpdate = true; + } + } + + Time++; + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int i = 0; i < 3; i++) + { + Dust magic = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Circular(12f, 12f), 264); + magic.color = Color.Red; + magic.velocity = Main.rand.NextVector2Circular(3f, 3f); + magic.fadeIn = 0.9f; + magic.scale = 1.3f; + magic.noGravity = true; + } + + if (npc.life <= 0) + { + for (int i = 0; i < 15; i++) + { + Dust magic = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Circular(12f, 12f), 264); + magic.color = Color.Red; + magic.velocity = Main.rand.NextVector2Circular(6f, 6f); + magic.fadeIn = 1.25f; + magic.scale = Main.rand.NextFloat(1.2f, 1.56f); + magic.noGravity = true; + } + } + } + + public override void NPCLoot() + { + for (int i = 0; i < 8; i++) + DropHelper.DropItem(npc, ItemID.Heart); + } + + public override Color? GetAlpha(Color drawColor) => Color.White * npc.Opacity; + } +} diff --git a/NPCs/Other/BrimstoneOrb.png b/NPCs/Other/BrimstoneOrb.png new file mode 100644 index 0000000000..680009c5da Binary files /dev/null and b/NPCs/Other/BrimstoneOrb.png differ diff --git a/NPCs/Other/CalamitasEnchantDemon.cs b/NPCs/Other/CalamitasEnchantDemon.cs new file mode 100644 index 0000000000..d4a60a001d --- /dev/null +++ b/NPCs/Other/CalamitasEnchantDemon.cs @@ -0,0 +1,163 @@ +using CalamityMod.Projectiles.Healing; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.Other +{ + public class CalamitasEnchantDemon : ModNPC + { + public Player Target => Main.player[npc.target]; + public ref float AttackTimer => ref npc.ai[0]; + public ref float FadeAwayTimer => ref npc.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Demon"); + Main.npcFrameCount[npc.type] = 5; + } + + public override void SetDefaults() + { + npc.width = 68; + npc.height = 68; + npc.damage = 0; + npc.defense = 0; + + // This is meant to be created after SCal is defeated and should be at least a little challenging. + npc.lifeMax = 101010; + npc.HitSound = SoundID.NPCHit47; + npc.DeathSound = SoundID.NPCDeath18; + npc.noGravity = true; + npc.noTileCollide = true; + npc.value = 0f; + npc.knockBackResist = 0f; + npc.netAlways = true; + npc.aiStyle = 0; + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 101010; + + public override void AI() + { + FadeAwayTimer++; + + // This npc should not attempt to locate other targets. The only one it will accept is the + // player who summoned it in the first place. + if (!Main.projectile.IndexInRange(npc.target) || Target.dead || !Target.active) + { + FadeAway(); + return; + } + + if (FadeAwayTimer < 15f) + { + DoInitializationAI(); + return; + } + + AttackTarget(); + } + + public void FadeAway() + { + npc.dontTakeDamage = true; + npc.Opacity = Utils.InverseLerp(50f, 0f, FadeAwayTimer, true); + + // Become inactive after fading away completely. + if (npc.Opacity <= 0f) + { + npc.active = false; + npc.netUpdate = true; + } + + // Slow down and fade away. + npc.velocity = Vector2.Lerp(npc.velocity, Vector2.UnitY * npc.Opacity * -2f, 0.125f); + + FadeAwayTimer++; + + if (Main.dedServ) + return; + + // Create some fade dust. + for (int i = 0; i < 3; i++) + { + Dust magic = Dust.NewDustDirect(npc.position, npc.width, npc.height, 223); + magic.velocity = -Vector2.UnitY * Main.rand.NextFloat(2.8f, 3.5f); + magic.scale = Main.rand.NextFloat(1f, 1.125f); + magic.fadeIn = 0.4f; + magic.noGravity = true; + magic.noLight = true; + } + } + + public void DoInitializationAI() + { + // Create a burst of magic on the first frame. + if (!Main.dedServ && FadeAwayTimer == 1f) + { + for (int i = 0; i < 50; i++) + { + Dust magic = Dust.NewDustDirect(npc.position, npc.width, npc.height, 223); + magic.velocity = -Vector2.UnitY * Main.rand.NextFloat(2.8f, 3.5f); + magic.scale = Main.rand.NextFloat(1f, 1.125f); + magic.fadeIn = 0.7f; + magic.noGravity = true; + magic.noLight = true; + } + } + + // Rise upward. + npc.velocity = Vector2.UnitX * MathHelper.Lerp(-0.1f, -3.5f, FadeAwayTimer / 15f); + } + + public void AttackTarget() + { + // Slow down prior to a charge. + if (AttackTimer % 120f > 90f) + npc.velocity *= 0.94f; + + // Otherwise attempt to move towards the player. + else if (!npc.WithinRange(Target.Center, 150f)) + { + Vector2 idealVelocity = npc.SafeDirectionTo(Target.Center) * 16f; + npc.velocity = (npc.velocity * 29f + idealVelocity) / 30f; + npc.velocity = Vector2.Lerp(npc.velocity, idealVelocity, 0.025f); + } + + // Charge. + if (AttackTimer % 120f == 119f) + npc.velocity = npc.SafeDirectionTo(Target.Center) * 23.5f; + + npc.spriteDirection = (npc.velocity.X < 0f).ToDirectionInt(); + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + if (npc.frameCounter % 5f == 4f) + npc.frame.Y += frameHeight; + + if (npc.frame.Y >= frameHeight * Main.npcFrameCount[npc.type]) + npc.frame.Y = 0; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + Utils.PoofOfSmoke(npc.Center); + + // Release 4 healing projectiles towards the target. + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < 4; i++) + { + Vector2 shootVelocity = npc.SafeDirectionTo(Target.Center).RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 14f); + Projectile.NewProjectile(npc.Center, shootVelocity, ModContent.ProjectileType(), 0, 0f, npc.target); + } + } + } + } + } +} diff --git a/NPCs/Other/CalamitasEnchantDemon.png b/NPCs/Other/CalamitasEnchantDemon.png new file mode 100644 index 0000000000..bd3a5924ca Binary files /dev/null and b/NPCs/Other/CalamitasEnchantDemon.png differ diff --git a/NPCs/Other/DemonPortal.cs b/NPCs/Other/DemonPortal.cs new file mode 100644 index 0000000000..092c7846ee --- /dev/null +++ b/NPCs/Other/DemonPortal.cs @@ -0,0 +1,123 @@ +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.Other +{ + public class DemonPortal : ModNPC + { + public ref float Time => ref npc.ai[0]; + public override void SetStaticDefaults() => DisplayName.SetDefault("Mysterious Portal"); + + public override void SetDefaults() + { + npc.width = npc.height = 60; + npc.damage = 0; + npc.defense = 0; + npc.lifeMax = 24660; + npc.noGravity = true; + npc.noTileCollide = true; + npc.value = 0f; + npc.knockBackResist = 0f; + npc.netAlways = true; + npc.aiStyle = -1; + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 24660; + + public override void AI() + { + npc.rotation += 0.18f; + npc.Opacity = Utils.InverseLerp(0f, 30f, Time, true) * Utils.InverseLerp(420f, 390f, Time, true); + npc.velocity = Vector2.Zero; + npc.scale = npc.Opacity; + + if (Time == 300f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + ReleaseThings(); + Main.PlaySound(SoundID.DD2_EtherianPortalOpen, npc.Center); + } + + if (Main.netMode != NetmodeID.MultiplayerClient && Time >= 420f) + { + npc.active = false; + npc.netUpdate = true; + } + + Time++; + } + + public void ReleaseThings() + { + bool friendly = npc.life == 1; + for (int i = 0; i < 6; i++) + { + int demon = Projectile.NewProjectile(npc.Center, Main.rand.NextVector2CircularEdge(4f, 4f), ModContent.ProjectileType(), 17000, 0f, npc.target); + if (Main.projectile.IndexInRange(demon)) + { + Main.projectile[demon].friendly = friendly; + Main.projectile[demon].hostile = !friendly; + } + } + } + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + bool wouldDie = npc.life - (damage * (crit ? 2D : 1D)) <= 0; + if (wouldDie) + { + npc.immortal = true; + + // Enrage demons if hit when already at 1 health. + if (npc.life == 1) + { + int demonType = ModContent.ProjectileType(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != demonType || !Main.projectile[i].active || Main.projectile[i].hostile) + continue; + + Main.projectile[i].hostile = true; + Main.projectile[i].friendly = false; + Main.projectile[i].netUpdate = true; + } + } + + npc.life = 1; + damage = 0D; + return false; + } + return true; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + spriteBatch.SetBlendState(BlendState.AlphaBlend); + + Texture2D portalTexture = Main.npcTexture[npc.type]; + Vector2 drawPosition = npc.Center - Main.screenPosition; + Vector2 origin = portalTexture.Size() * 0.5f; + Color baseColor = Color.White; + + // Purple-black portal. + Color color = Color.Lerp(baseColor, Color.Black, 0.55f) * npc.Opacity * 1.8f; + spriteBatch.Draw(portalTexture, drawPosition, null, color, npc.rotation, origin, npc.scale * 1.2f, SpriteEffects.None, 0f); + spriteBatch.Draw(portalTexture, drawPosition, null, color, -npc.rotation, origin, npc.scale * 1.2f, SpriteEffects.None, 0f); + + // Purple portal. + color = Color.Lerp(Color.Lerp(baseColor, Color.Purple, 0.55f), Color.Black, 0.66f) * npc.Opacity * 1.6f; + spriteBatch.Draw(portalTexture, drawPosition, null, color, npc.rotation * 0.6f, origin, npc.scale * 1.2f, SpriteEffects.None, 0f); + + // Red portal. + color = Color.Lerp(baseColor, Color.Red, 0.55f) * npc.Opacity * 1.6f; + spriteBatch.Draw(portalTexture, drawPosition, null, color, npc.rotation * -0.6f, origin, npc.scale * 1.2f, SpriteEffects.None, 0f); + + spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; + } + } +} diff --git a/NPCs/Other/DemonPortal.png b/NPCs/Other/DemonPortal.png new file mode 100644 index 0000000000..1fb1ceee5e Binary files /dev/null and b/NPCs/Other/DemonPortal.png differ diff --git a/NPCs/Other/ExhumedHeart.cs b/NPCs/Other/ExhumedHeart.cs new file mode 100644 index 0000000000..bfde229cb5 --- /dev/null +++ b/NPCs/Other/ExhumedHeart.cs @@ -0,0 +1,67 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.Other +{ + public class ExhumedHeart : ModNPC + { + public ref float Time => ref npc.ai[0]; + public Player Owner + { + get + { + if (npc.target >= 255 || npc.target < 0) + npc.TargetClosest(); + return Main.player[npc.target]; + } + } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Exhumed Brimstone Heart"); + Main.npcFrameCount[npc.type] = 6; + } + + public override void SetDefaults() + { + npc.width = npc.height = 38; + npc.damage = 0; + npc.defense = 0; + npc.lifeMax = 51740; + npc.noGravity = true; + npc.noTileCollide = true; + npc.value = 0f; + npc.HitSound = SoundID.NPCHit13; + npc.DeathSound = SoundID.NPCDeath1; + npc.knockBackResist = 0f; + npc.netAlways = true; + npc.aiStyle = -1; + npc.Calamity().DoesNotGenerateRage = true; + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 51740; + + public override void AI() + { + npc.Opacity = Utils.InverseLerp(0f, 25f, Time, true); + npc.Center = Owner.Center + (MathHelper.TwoPi * Time / 540f).ToRotationVector2() * 350f; + npc.velocity = Vector2.Zero; + + Time++; + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + npc.frame.Y = (int)(npc.frameCounter / 5) % Main.npcFrameCount[npc.type] * frameHeight; + } + + public override Color? GetAlpha(Color drawColor) + { + Color color = Color.Purple * npc.Opacity; + color.A = 127; + return color; + } + } +} diff --git a/NPCs/Other/ExhumedHeart.png b/NPCs/Other/ExhumedHeart.png new file mode 100644 index 0000000000..c597cfe505 Binary files /dev/null and b/NPCs/Other/ExhumedHeart.png differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 72ca0be300..8669ddac3f 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -13,6 +13,7 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.NPCs.TownNPCs; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -568,7 +569,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas forcefieldOpacity = Utils.InverseLerp(0.1f, 0.6f, npc.Opacity, true); if (npc.alpha >= 230) { - // TODO: Spawn the town NPC variant of SCal here when it's on the public branch. + if (CalamityWorld.downedSCal && !BossRushEvent.BossRushActive) + { + // Create a teleport line effect + Dust.QuickDustLine(npc.Center, initialRitualPosition, 500f, Color.Red); + npc.Center = initialRitualPosition; + + // Make the town NPC spawn. + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y + 12, ModContent.NPCType()); + } + npc.active = false; npc.netUpdate = true; } @@ -995,7 +1006,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (CalamityWorld.downedSCal && !BossRushEvent.BossRushActive) { - // TODO: Spawn the town NPC variant of SCal again here. if (giveUpCounter == 720) { for (int i = 0; i < 24; i++) @@ -2723,6 +2733,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas Dust.QuickDustLine(npc.Center, initialRitualPosition, 500f, Color.Red); npc.Center = initialRitualPosition; + // Make the town NPC spawn. + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y + 12, ModContent.NPCType()); + // Increase the player's SCal kill count if (Main.player[npc.target].Calamity().sCalKillCount < 5) Main.player[npc.target].Calamity().sCalKillCount++; diff --git a/NPCs/TownNPCs/WITCH.cs b/NPCs/TownNPCs/WITCH.cs new file mode 100644 index 0000000000..0313ce6017 --- /dev/null +++ b/NPCs/TownNPCs/WITCH.cs @@ -0,0 +1,157 @@ +using CalamityMod.Dusts; +using CalamityMod.Events; +using CalamityMod.Items; +using CalamityMod.Projectiles.Magic; +using CalamityMod.UI.CalamitasEnchants; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent.Events; +using Terraria.ID; +using Terraria.ModLoader; + +using static Terraria.ModLoader.ModContent; +using SCalBoss = CalamityMod.NPCs.SupremeCalamitas.SupremeCalamitas; + +namespace CalamityMod.NPCs.TownNPCs +{ + [AutoloadHead] + public class WITCH : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brimstone Witch"); + + Main.npcFrameCount[npc.type] = 27; + NPCID.Sets.ExtraFramesCount[npc.type] = 9; + NPCID.Sets.AttackFrameCount[npc.type] = 4; + NPCID.Sets.DangerDetectRange[npc.type] = 700; + NPCID.Sets.AttackType[npc.type] = 1; + NPCID.Sets.AttackTime[npc.type] = 30; + NPCID.Sets.AttackAverageChance[npc.type] = 5; + } + + public override void SetDefaults() + { + npc.townNPC = true; + npc.friendly = true; + npc.lavaImmune = true; + npc.width = 18; + npc.height = 40; + npc.aiStyle = 7; + npc.damage = 10; + + // You should not be able to kill SCal under any typical circumstances. + npc.Calamity().DR = 0.999999f; + npc.Calamity().unbreakableDR = true; + npc.lifeMax = 1000000; + + npc.defense = 120; + npc.HitSound = SoundID.NPCHit1; + npc.DeathSound = SoundID.NPCDeath6; + npc.knockBackResist = 0.8f; + animationType = NPCID.Wizard; + } + + public override bool CanTownNPCSpawn(int numTownNPCs, int money) => CalamityWorld.downedSCal; + + public override string TownNPCName() => "Calamitas"; + + public override string GetChat() => "Mrrp is cringe."; + + public override void SetChatButtons(ref string button, ref string button2) => button = "Enchant"; + + public override void OnChatButtonClicked(bool firstButton, ref bool shop) + { + if (firstButton) + { + Main.playerInventory = true; + Main.LocalPlayer.Calamity().newCalamitasInventory = false; + CalamitasEnchantUI.NPCIndex = npc.whoAmI; + CalamitasEnchantUI.CurrentlyViewing = true; + + if (!Main.LocalPlayer.Calamity().GivenBrimstoneLocus) + { + DropHelper.DropItem(npc, ItemType()); + Main.LocalPlayer.Calamity().GivenBrimstoneLocus = true; + } + + shop = false; + } + } + + // Make this Town NPC teleport to the Queen statue when triggered. + public override bool CanGoToStatue(bool toKingStatue) => !toKingStatue; + + public override void TownNPCAttackStrength(ref int damage, ref float knockback) + { + damage = 50; + knockback = 10f; + } + + public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown) + { + cooldown = 10; + randExtraCooldown = 50; + } + + public override bool PreAI() + { + // Disappear if the SCal boss is active. She's supposed to be the boss. + // However, this doesn't happen in Boss Rush; the SCal there is a silent puppet created by Xeroc, not SCal herself. + if (NPC.AnyNPCs(NPCType()) && !BossRushEvent.BossRushActive) + { + npc.active = false; + npc.netUpdate = true; + return false; + } + return true; + } + + //public override void TownNPCAttackMagic(ref float auraLightMultiplier) + + public override void TownNPCAttackProj(ref int projType, ref int attackDelay) + { + projType = ProjectileType(); + attackDelay = 1; + } + + public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset) + { + multiplier = 2f; + } + + // Explode into red dust on death. + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + npc.position = npc.Center; + npc.width = npc.height = 50; + npc.position.X -= npc.width / 2; + npc.position.Y -= npc.height / 2; + for (int i = 0; i < 5; i++) + { + int brimstone = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimstone].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[brimstone].scale = 0.5f; + Main.dust[brimstone].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + + for (int i = 0; i < 10; i++) + { + int fire = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[fire].noGravity = true; + Main.dust[fire].velocity *= 5f; + + fire = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[fire].velocity *= 2f; + } + } + } + } +} diff --git a/NPCs/TownNPCs/WITCH.png b/NPCs/TownNPCs/WITCH.png new file mode 100644 index 0000000000..7c02e35630 Binary files /dev/null and b/NPCs/TownNPCs/WITCH.png differ diff --git a/NPCs/TownNPCs/WITCH_Head.png b/NPCs/TownNPCs/WITCH_Head.png new file mode 100644 index 0000000000..8869c7a345 Binary files /dev/null and b/NPCs/TownNPCs/WITCH_Head.png differ 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/Particles/FireParticleSet.cs b/Particles/FireParticleSet.cs new file mode 100644 index 0000000000..fd362b1a76 --- /dev/null +++ b/Particles/FireParticleSet.cs @@ -0,0 +1,44 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class FireParticleSet : BaseParticleSet + { + public float SpawnAreaCompactness; + public float RelativePower; + public Color BrightColor; + public Color DarkColor; + public override int ParticleLifetime => 50; + public override Texture2D ParticleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Particles/Fire"); + public FireParticleSet(int setLifetime, int particleSpawnRate, Color brightColor, Color darkColor, float spawnAreaCompactness, float relativePower) : + base(setLifetime, particleSpawnRate) + { + BrightColor = brightColor; + DarkColor = darkColor; + SpawnAreaCompactness = spawnAreaCompactness; + RelativePower = relativePower; + } + + public override void UpdateBehavior(Particle particle) + { + particle.Scale += RelativePower * 0.01f; + particle.RelativeOffset.Y -= RelativePower * 3f; + } + + public override Color DetermineParticleColor(float lifetimeCompletion) + { + Color particleColor = Color.Lerp(BrightColor, DarkColor, lifetimeCompletion); + particleColor = Color.Lerp(particleColor, Color.SaddleBrown, Utils.InverseLerp(0.95f, 0.7f, lifetimeCompletion, true)); + particleColor = Color.Lerp(particleColor, Color.White, Utils.InverseLerp(0.1f, 0.25f, lifetimeCompletion, true) * Utils.InverseLerp(0.4f, 0.25f, lifetimeCompletion, true) * 0.7f); + particleColor *= Utils.InverseLerp(0f, 0.15f, lifetimeCompletion, true) * Utils.InverseLerp(1f, 0.8f, lifetimeCompletion, true) * 0.6f; + particleColor.A = 50; + + return particleColor; + } + + public override Particle SpawnParticle() => new Particle(ParticleLifetime, Main.rand.NextVector2Circular(1f, 1f) * SpawnAreaCompactness, 0.06f); + } +} \ No newline at end of file diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index a8e8b82a10..e5b2eb1430 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Events; @@ -8,6 +9,7 @@ using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Melee.Yoyos; using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -112,8 +114,12 @@ namespace CalamityMod.Projectiles public const float MaliceModeProjectileVelocityMultiplier = 1.25f; public const float BossRushProjectileVelocityMultiplier = 1.35f; - #region SetDefaults - public override void SetDefaults(Projectile projectile) + // Enchantment variables. + public int ExplosiveEnchantCountdown = 0; + public const int ExplosiveEnchantTime = 2400; + + #region SetDefaults + public override void SetDefaults(Projectile projectile) { if (CalamityLists.trueMeleeProjectileList.Contains(projectile.type)) trueMelee = true; @@ -249,6 +255,47 @@ namespace CalamityMod.Projectiles #region PreAI public override bool PreAI(Projectile projectile) { + if (projectile.minion && ExplosiveEnchantCountdown > 0) + { + ExplosiveEnchantCountdown--; + if (defDamage == 0) + defDamage = projectile.damage; + projectile.damage = (int)(defDamage * MathHelper.SmoothStep(1f, 1.6f, 1f - ExplosiveEnchantCountdown / (float)ExplosiveEnchantTime)); + + // Make fizzle sounds and fire dust to indicate the impending explosion. + if (ExplosiveEnchantCountdown <= 300) + { + if (Main.rand.NextBool(24)) + Main.PlaySound(SoundID.DD2_BetsyFireballShot, projectile.Center); + + Dust fire = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(projectile.width, projectile.height) * 0.42f, 267); + fire.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0.45f, 1f)); + fire.scale = Main.rand.NextFloat(1.4f, 1.65f); + fire.fadeIn = 0.5f; + fire.noGravity = true; + } + + if (ExplosiveEnchantCountdown % 40 == 39 && Main.rand.NextBool(12)) + { + int damage = (int)(Main.player[projectile.owner].MinionDamage() * 2000); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), damage, 0f, projectile.owner); + } + + if (ExplosiveEnchantCountdown <= 0) + { + Main.PlaySound(SoundID.DD2_KoboldExplosion, projectile.Center); + if (Main.myPlayer == projectile.owner) + { + if (projectile.minionSlots > 0f) + { + int damage = (int)(Main.player[projectile.owner].MinionDamage() * 6000); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), damage, 0f, projectile.owner); + } + projectile.Kill(); + } + } + } + if (RequiresManualResurrection) { // Reactivate the projectile the instant it's created. This is dirty as fuck, but @@ -2055,6 +2102,23 @@ namespace CalamityMod.Projectiles organicEnemyHitEffect?.Invoke(target); } } + + if (modPlayer.flamingItemEnchant && !projectile.minion) + target.AddBuff(BuffType(), 420); + + if (modPlayer.farProximityRewardEnchant) + { + float proximityDamageInterpolant = Utils.InverseLerp(250f, 2400f, target.Distance(player.Center), true); + float proximityDamageFactor = MathHelper.SmoothStep(0.7f, 1.45f, proximityDamageInterpolant); + damage = (int)Math.Ceiling(damage * proximityDamageFactor); + } + + if (modPlayer.closeProximityRewardEnchant) + { + float proximityDamageInterpolant = Utils.InverseLerp(400f, 175f, target.Distance(player.Center), true); + float proximityDamageFactor = MathHelper.SmoothStep(0.75f, 1.75f, proximityDamageInterpolant); + damage = (int)Math.Ceiling(damage * proximityDamageFactor); + } if (!projectile.npcProj && !projectile.trap && rogue && stealthStrike && modPlayer.stealthStrikeAlwaysCrits) crit = true; diff --git a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs index c6b5a6c1c5..e03bec6fec 100644 --- a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs +++ b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // This both checks if the player has sufficient mana and consumes it if they do. // If this is false, the Gatling Laser stops functioning. - bool hasMana = player.CheckMana(gatling.mana, true, false); + bool hasMana = player.CheckMana(gatling, -1, true, false); // Checks if the Gatling Laser has sufficient charge to fire. If this is false, it stops functioning. CalamityGlobalItem modItem = gatling.Calamity(); diff --git a/Projectiles/Healing/DemonHeal.cs b/Projectiles/Healing/DemonHeal.cs new file mode 100644 index 0000000000..fcff05e107 --- /dev/null +++ b/Projectiles/Healing/DemonHeal.cs @@ -0,0 +1,33 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Healing +{ + public class DemonHeal : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() => DisplayName.SetDefault("Heal"); + + public override void SetDefaults() + { + projectile.width = 4; + projectile.height = 4; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.timeLeft = 640; + } + + public override void AI() + { + projectile.HealingProjectile(10, projectile.owner, 20f, 20f, true, 640); + + Dust fire = Dust.NewDustPerfect(projectile.Center, 130); + fire.velocity = Microsoft.Xna.Framework.Vector2.Zero; + fire.scale = Main.rand.NextFloat(1f, 1.15f); + fire.fadeIn = 0.45f; + fire.noGravity = true; + } + } +} diff --git a/Projectiles/Magic/ApotheosisEnergy.cs b/Projectiles/Magic/ApotheosisEnergy.cs index 30c346c073..0b27b1b7fe 100644 --- a/Projectiles/Magic/ApotheosisEnergy.cs +++ b/Projectiles/Magic/ApotheosisEnergy.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Projectiles.Magic baseColor = Color.Lerp(baseColor, Color.Fuchsia, (completionRatio - 0.66f) / 0.33f); else { - float whiteFade = (float)Math.Sin(Utils.InverseLerp(0.1f, 0.56f, completionRatio, true) * MathHelper.Pi + Main.GlobalTime * 10f) * 0.85f; + float whiteFade = (float)Math.Sin(Utils.InverseLerp(0.0f, 0.2f, completionRatio, true) * MathHelper.Pi + Main.GlobalTime * 3f) * 0.45f; baseColor = Color.Lerp(baseColor, Color.White, whiteFade); } diff --git a/Projectiles/Magic/ApotheosisWorm.cs b/Projectiles/Magic/ApotheosisWorm.cs index 77e904b95b..dd7c1fa2ec 100644 --- a/Projectiles/Magic/ApotheosisWorm.cs +++ b/Projectiles/Magic/ApotheosisWorm.cs @@ -317,7 +317,7 @@ namespace CalamityMod.Projectiles.Magic colorA *= currentFade; colorB *= currentFade; Vector2 origin = texture.Size() / 2f; - Vector2 scale = new Vector2(8f, 19f) * projectile.Opacity * currentFade; + Vector2 scale = new Vector2(4f, 10f) * projectile.Opacity * currentFade; spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, SpriteEffects.None, 0); spriteBatch.Draw(texture, drawPos, null, colorA, 0f, origin, scale, SpriteEffects.None, 0); diff --git a/Projectiles/Magic/DarkSparkPrism.cs b/Projectiles/Magic/DarkSparkPrism.cs index 0fde8c1dfa..009b32ccca 100644 --- a/Projectiles/Magic/DarkSparkPrism.cs +++ b/Projectiles/Magic/DarkSparkPrism.cs @@ -125,7 +125,7 @@ namespace CalamityMod.Projectiles.Magic if (flag10 && Main.myPlayer == projectile.owner) { - bool flag11 = !flag9 || player.CheckMana(player.ActiveItem().mana, true, false); + bool flag11 = !flag9 || player.CheckMana(player.ActiveItem(), -1, true, false); bool flag12 = player.channel && flag11 && !player.noItems && !player.CCed; if (flag12) { diff --git a/Projectiles/Magic/ManaMonster.cs b/Projectiles/Magic/ManaMonster.cs new file mode 100644 index 0000000000..934b90e21c --- /dev/null +++ b/Projectiles/Magic/ManaMonster.cs @@ -0,0 +1,106 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class ManaMonster : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public Player Target => Main.player[projectile.owner]; + public const int NPCAttackTime = 50; + public const int PlayerAttackRedirectTime = 45; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Monster"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 52; + projectile.friendly = true; + projectile.hostile = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.timeLeft = 300; + projectile.Opacity = 0f; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 5; + projectile.magic = true; + } + + public override void AI() + { + if (Time < NPCAttackTime) + { + projectile.Opacity = Utils.InverseLerp(0f, 30f, Time, true); + if (projectile.velocity.Length() < 27f) + projectile.velocity *= 1.05f; + } + else + { + // Make an alert sound to indicate that the monster has become enraged and will now attack its caster. + if (Time == NPCAttackTime) + { + int ambientNoiseID = Main.rand.Next(39, 41 + 1); + Main.PlaySound(SoundID.Zombie, Target.Center, ambientNoiseID); + Main.PlaySound(SoundID.DD2_DrakinShot, Target.Center); + CreateTransitionBurstDust(); + } + + if (Time < NPCAttackTime + PlayerAttackRedirectTime) + { + float idealMovementDirection = projectile.AngleTo(Target.Center); + float angularTurnSpeed = 0.09f; + float newSpeed = MathHelper.Lerp(projectile.velocity.Length(), 22f, 0.1f); + projectile.velocity = projectile.velocity.ToRotation().AngleTowards(idealMovementDirection, angularTurnSpeed).ToRotationVector2() * newSpeed; + } + else if (projectile.velocity.Length() < 35f) + projectile.velocity *= 1.04f; + + // Fade out. + projectile.Opacity = Utils.InverseLerp(0f, 15f, projectile.timeLeft, true); + } + + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + Time++; + } + + public void CreateTransitionBurstDust() + { + if (Main.dedServ) + return; + + for (int i = 0; i < 75; i++) + { + Dust brimstone = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Square(-25f, 25f), (int)CalamityDusts.Brimstone); + brimstone.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 3.1f) * MathHelper.Lerp(1f, 2.175f, i / 75f); + brimstone.velocity = Vector2.Lerp(brimstone.velocity, -Vector2.UnitY * brimstone.velocity.Length(), 0.5f); + brimstone.scale = MathHelper.Lerp(1f, 1.875f, i / 75f) * Main.rand.NextFloat(0.8f, 1f); + brimstone.fadeIn = 0.4f; + brimstone.noGravity = true; + } + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + // Ensure damage is not absolutely obscene when hitting players. + damage = Main.rand.Next(150, 225); + } + + public override bool CanDamage() => projectile.Opacity >= 1f; + + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } +} diff --git a/Projectiles/Magic/ManaMonster.png b/Projectiles/Magic/ManaMonster.png new file mode 100644 index 0000000000..9b98b7bad0 Binary files /dev/null and b/Projectiles/Magic/ManaMonster.png differ diff --git a/Projectiles/Magic/PurgeProj.cs b/Projectiles/Magic/PurgeProj.cs index f6357b097f..e0d68f4db5 100644 --- a/Projectiles/Magic/PurgeProj.cs +++ b/Projectiles/Magic/PurgeProj.cs @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Magic if (flag && Main.myPlayer == projectile.owner) { int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); - bool flag2 = player.channel && player.CheckMana(player.ActiveItem().mana, true, false) && !player.noItems && !player.CCed; + bool flag2 = player.channel && player.CheckMana(player.ActiveItem(), -1, true, false) && !player.noItems && !player.CCed; if (flag2) { float speed = player.ActiveItem().shootSpeed * projectile.scale; diff --git a/Projectiles/Magic/SeethingDischargeBrimstoneHellblast.cs b/Projectiles/Magic/SeethingDischargeBrimstoneHellblast.cs index 99f5ca7523..7fde79c1bc 100644 --- a/Projectiles/Magic/SeethingDischargeBrimstoneHellblast.cs +++ b/Projectiles/Magic/SeethingDischargeBrimstoneHellblast.cs @@ -10,6 +10,7 @@ namespace CalamityMod.Projectiles.Magic { public class SeethingDischargeBrimstoneHellblast : ModProjectile { + private bool initialized = false; public override string Texture => "CalamityMod/Projectiles/Boss/BrimstoneHellblast"; public override void SetStaticDefaults() @@ -35,6 +36,16 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { + if (!initialized) + { + if (projectile.npcProj) + { + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 5; + projectile.penetrate = 10; + } + initialized = true; + } projectile.frameCounter++; if (projectile.frameCounter >= 10) { diff --git a/Projectiles/Magic/SparklingBeam.cs b/Projectiles/Magic/SparklingBeam.cs index 7c188ee5f6..0ed8ed8033 100644 --- a/Projectiles/Magic/SparklingBeam.cs +++ b/Projectiles/Magic/SparklingBeam.cs @@ -229,7 +229,7 @@ namespace CalamityMod.Projectiles.Magic } else { // Do we still have enough mana? If not, we kill the projectile because we cannot use it anymore - if (Main.player[projectile.owner].miscCounter % 10 == 0 && !player.CheckMana(player.ActiveItem().mana, true)) + if (Main.player[projectile.owner].miscCounter % 10 == 0 && !player.CheckMana(player.ActiveItem(), -1, true)) { projectile.Kill(); } diff --git a/Projectiles/Magic/T1000Proj.cs b/Projectiles/Magic/T1000Proj.cs index aec9a410c4..caebb2cf30 100644 --- a/Projectiles/Magic/T1000Proj.cs +++ b/Projectiles/Magic/T1000Proj.cs @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Magic if (flag && Main.myPlayer == projectile.owner) { int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); - bool flag2 = player.channel && player.CheckMana(player.ActiveItem().mana, true, false) && !player.noItems && !player.CCed; + bool flag2 = player.channel && player.CheckMana(player.ActiveItem(), -1, true, false) && !player.noItems && !player.CCed; if (flag2) { float speed = player.ActiveItem().shootSpeed * projectile.scale; diff --git a/Projectiles/Magic/YharimsCrystalPrism.cs b/Projectiles/Magic/YharimsCrystalPrism.cs index 9f8a3703a5..7447510c99 100644 --- a/Projectiles/Magic/YharimsCrystalPrism.cs +++ b/Projectiles/Magic/YharimsCrystalPrism.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Projectiles.Magic UpdateAim(rrp, speedTimesScale); // CheckMana returns true if the mana cost can be paid. If mana isn't consumed this frame, the CheckMana short-circuits out of being evaluated. - bool allowContinuedUse = !ShouldConsumeMana() || player.CheckMana(player.ActiveItem().mana, true, false); + bool allowContinuedUse = !ShouldConsumeMana() || player.CheckMana(player.ActiveItem(), -1, true, false); bool crystalStillInUse = player.channel && allowContinuedUse && !player.noItems && !player.CCed; // The beams are only projected once (on frame 1). diff --git a/Projectiles/Melee/TaintedBladeSlasher.cs b/Projectiles/Melee/TaintedBladeSlasher.cs new file mode 100644 index 0000000000..7d493cda46 --- /dev/null +++ b/Projectiles/Melee/TaintedBladeSlasher.cs @@ -0,0 +1,283 @@ +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class TaintedBladeSlasher : ModProjectile + { + internal PrimitiveTrail TrailDrawer = null; + public ref float SwordItemID => ref projectile.ai[1]; + public ref float VerticalOffset => ref projectile.localAI[0]; + 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 => (int)projectile.ai[0] % 2; + + public const float ForearmLength = 80f; + public const float ArmLength = 108f; + + public Rectangle BladeFrame + { + get + { + Texture2D bladeTexture = Main.itemTexture[(int)SwordItemID]; + Rectangle bladeFrame = bladeTexture.Frame(1, 1, 0, 0); + bool hasMultipleFrames = Main.itemAnimations[(int)SwordItemID] != null; + if (hasMultipleFrames) + bladeFrame = Main.itemAnimations[(int)SwordItemID].GetFrame(bladeTexture); + return bladeFrame; + } + } + + public Vector2 BackArmAimPosition + { + get + { + Vector2 baseAimPosition = Owner.Top + new Vector2(-Owner.direction * (ForearmLength + Math.Abs(VerticalOffset) * 0.55f), -27f); + if (Variant == 1) + baseAimPosition.Y += 30f; + if (Owner.itemAnimation == 0) + return baseAimPosition; + + Vector2 endSwingPosition = Owner.Center + Vector2.UnitX * Owner.direction * 510f; + return Vector2.SmoothStep(baseAimPosition, endSwingPosition, Utils.InverseLerp(0f, 0.67f, AttackCompletionRatio, true) * Utils.InverseLerp(1f, 0.67f, AttackCompletionRatio, true)); + } + } + public Vector2 IdleMoveOffset + { + get + { + Vector2 offset = Owner.itemAnimation == 0 ? (Time / 27f).ToRotationVector2() * new Vector2(5f, 4f) : Vector2.Zero; + if (Variant == 1) + offset += Vector2.UnitX * Owner.direction * (1f - AttackCompletionRatio) * 40f; + return offset; + } + } + public Vector2 FrontArmEnd + { + get + { + float backArmRotation = Owner.AngleTo(BackArmAimPosition); + Vector2 fromArmDrawPosition = Owner.Center + backArmRotation.ToRotationVector2() * ForearmLength; + Vector2 backOffset = (projectile.Center - fromArmDrawPosition).SafeNormalize(Vector2.Zero) * ArmLength + IdleMoveOffset; + return fromArmDrawPosition + backOffset; + } + } + public Vector2 BladeOffsetDirection + { + get + { + float backArmRotation = Owner.AngleTo(BackArmAimPosition); + Vector2 fromArmDrawPosition = Owner.Center + backArmRotation.ToRotationVector2() * ForearmLength; + Vector2 backOffset = (projectile.Center - fromArmDrawPosition).SafeNormalize(Vector2.Zero) * ArmLength + IdleMoveOffset; + float bladeRotation = backOffset.ToRotation() - MathHelper.PiOver4 + MathHelper.Pi; + return -(bladeRotation + MathHelper.PiOver4 + BladeRotationOffset).ToRotationVector2(); + } + } + public Vector2 BladeCenterPosition + { + get + { + float offsetFactor = BladeFrame.Height / 4f + 31f; + return FrontArmEnd + BladeOffsetDirection * offsetFactor; + } + } + public float BladeRotationOffset => MathHelper.Lerp(MathHelper.PiOver2, 0f, Utils.InverseLerp(0f, 0.17f, 1f - AttackCompletionRatio, true)) * -Owner.direction; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Blade"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 70; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 4; + projectile.friendly = true; + projectile.melee = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = 90000; + projectile.usesLocalNPCImmunity = true; + projectile.noEnchantments = true; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(VerticalOffset); + + public override void ReceiveExtraAI(BinaryReader reader) => VerticalOffset = reader.ReadSingle(); + + public override void AI() + { + CalamityPlayerMiscEffects.EnchantHeldItemEffects(Owner, Owner.Calamity(), Owner.ActiveItem()); + if (!Owner.Calamity().bladeArmEnchant || Owner.ActiveItem().type != SwordItemID || 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. + if (Variant == 1) + swingOffsetAngle -= 0.7f; + swingOffsetAngle *= Owner.direction; + swingOffsetAngle = MathHelper.Lerp(0f, swingOffsetAngle, Utils.InverseLerp(0f, 0.16f, AttackCompletionRatio, true)); + + if (Owner.itemAnimation == 0) + swingOffsetAngle = 0f; + + Vector2 destination = Owner.Center; + + if (Owner.itemAnimation == 0) + { + destination.X += Owner.direction * (VerticalOffset * 0.6f + 180f); + destination.Y += 330f + VerticalOffset; + if (Variant == 1) + destination.Y += 540f; + + // The blade can be kept in a static location when not being swung. + // This can result in insane damage coming from "poking" enemies. + // To accomodate for this, the hit countdown is increased when not attacking. + projectile.localNPCHitCooldown = 24; + } + else + { + // Swing around in an arc as needed. + // One arm extends a little bit further than the other. + destination -= Vector2.UnitY.RotatedBy(swingOffsetAngle) * 600f; + + // Make a fire/swing sound. + if (Owner.itemAnimation == 21) + Main.PlaySound(SoundID.DD2_FlameburstTowerShot, Owner.Center); + projectile.localNPCHitCooldown = 3; + } + + if (AttackCompletionRatio < 0.16f) + projectile.oldPos = new Vector2[projectile.oldPos.Length]; + + // Very, very quickly approach the swing destination while attacking. + // Also gain a temporary extra update. + if (Owner.itemAnimation > 0) + { + projectile.Center = Vector2.Lerp(projectile.Center, destination, 0.19f); + projectile.extraUpdates = 1; + } + + // Idly move towards the destination. + 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++; + } + + internal float PrimitiveWidthFunction(float completionRatio) => BladeFrame.Height * 0.47f; + + internal Color PrimitiveColorFunction(float completionRatio) + { + float opacity = Utils.InverseLerp(0.8f, 0.52f, completionRatio, true) * Utils.InverseLerp(1f, 0.81f, AttackCompletionRatio, true); + Color startingColor = Color.Lerp(Color.Red, Color.DarkRed, 0.4f); + Color endingColor = Color.Lerp(Color.DarkRed, Color.Purple, 0.77f); + return Color.Lerp(startingColor, endingColor, (float)Math.Pow(completionRatio, 0.37f)) * opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:FadingSolidTrail"]); + + Texture2D forearmTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/TaintedForearm"); + Texture2D armTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/TaintedArm"); + Texture2D handTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/TaintedHand"); + + // Reflect the 1st hand variant horizontally. + SpriteEffects handDirection = SpriteEffects.None; + if (Variant == (Owner.direction == -1).ToInt()) + { + handTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/TaintedHand2"); + handDirection = SpriteEffects.FlipHorizontally; + } + Texture2D bladeTexture = Main.itemTexture[(int)SwordItemID]; + + // Draw the arms. + float backArmRotation = Owner.AngleTo(BackArmAimPosition); + spriteBatch.Draw(forearmTexture, Owner.Center - Main.screenPosition, null, Color.White, backArmRotation - MathHelper.PiOver2, Vector2.UnitX * forearmTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + + Vector2 frontArmDrawPosition = Owner.Center + backArmRotation.ToRotationVector2() * ForearmLength + IdleMoveOffset; + float frontArmRotation = projectile.AngleFrom(frontArmDrawPosition); + spriteBatch.Draw(armTexture, frontArmDrawPosition - Main.screenPosition, null, Color.White, frontArmRotation - MathHelper.PiOver2, Vector2.UnitX * armTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + + float handRotation = frontArmRotation + MathHelper.PiOver2 + MathHelper.Pi; + float bladeRotation = handRotation - MathHelper.PiOver4 + MathHelper.Pi + BladeRotationOffset; + if (Owner.direction == -1) + bladeRotation += MathHelper.PiOver2; + + // Draw the trail behind the blade. + if (Owner.itemAnimation > 0) + { + GameShaders.Misc["CalamityMod:FadingSolidTrail"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/BladeTrailUVMap")); + GameShaders.Misc["CalamityMod:FadingSolidTrail"].Shader.Parameters["shouldFlip"].SetValue((float)(Owner.direction == -1).ToInt()); + + Vector2 bottom = BladeCenterPosition - BladeOffsetDirection * BladeFrame.Height * 0.5f - Main.screenPosition; + Vector2 top = BladeCenterPosition + BladeOffsetDirection * BladeFrame.Height * 0.5f - Main.screenPosition; + Vector2 offsetToBlade = (top - bottom).SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver2) * 5f; + + TrailDrawer.OverridingStickPointStart = BladeCenterPosition - BladeOffsetDirection * BladeFrame.Height * 0.5f + offsetToBlade - Main.screenPosition; + TrailDrawer.OverridingStickPointEnd = BladeCenterPosition + BladeOffsetDirection * BladeFrame.Height * 0.5f + offsetToBlade - Main.screenPosition; + + // Swap the ends if needed so that the trail faces the right direction. + if (Owner.direction == -1) + Utils.Swap(ref TrailDrawer.OverridingStickPointStart, ref TrailDrawer.OverridingStickPointEnd); + + Vector2[] drawPoints = new Vector2[projectile.oldPos.Length]; + Vector2 perpendicularDirection = BladeOffsetDirection.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.PiOver2); + for (int i = 1; i < drawPoints.Length; i++) + { + if (projectile.oldPos[i] == Vector2.Zero) + continue; + + drawPoints[i] = projectile.Center + perpendicularDirection.RotatedBy(i * -0.014f * Owner.direction) * i * -Owner.direction * 6f; + } + + TrailDrawer.Draw(drawPoints, BladeCenterPosition - projectile.position - Main.screenPosition, 67); + } + + // Draw the blade. + Vector2 bladeDrawPosition = BladeCenterPosition - Main.screenPosition; + SpriteEffects bladeDirection = Owner.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(bladeTexture, bladeDrawPosition, BladeFrame, Color.White, bladeRotation, BladeFrame.Size() * 0.5f, projectile.scale, bladeDirection, 0f); + + // Draw the hand. + spriteBatch.Draw(handTexture, FrontArmEnd - Main.screenPosition, null, projectile.GetAlpha(Color.White), handRotation, handTexture.Size() * 0.5f, projectile.scale, handDirection, 0f); + return false; + } + + // Register collision at the blade's position. + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + Vector2 start = BladeCenterPosition - BladeOffsetDirection * BladeFrame.Height * 0.5f; + Vector2 end = BladeCenterPosition + BladeOffsetDirection * BladeFrame.Height * 0.5f; + float width = 60f; + float _ = 0f; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, width, ref _); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + ItemLoader.OnHitNPC(Owner.ActiveItem(), Owner, target, damage, knockback, crit); + NPCLoader.OnHitByItem(target, Owner, Owner.ActiveItem(), damage, knockback, crit); + PlayerHooks.OnHitNPC(Owner, Owner.ActiveItem(), target, damage, knockback, crit); + } + } +} diff --git a/Projectiles/Ranged/ContagionBow.cs b/Projectiles/Ranged/ContagionBow.cs index c7382b46ee..89ac2dd550 100644 --- a/Projectiles/Ranged/ContagionBow.cs +++ b/Projectiles/Ranged/ContagionBow.cs @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Ranged } if (flag && Main.myPlayer == projectile.owner) { - bool flag2 = player.channel && player.CheckMana(player.ActiveItem().mana, true, false) && !player.noItems && !player.CCed; + bool flag2 = player.channel && !player.noItems && !player.CCed; if (flag2) { float speed = player.ActiveItem().shootSpeed * projectile.scale; diff --git a/Projectiles/Ranged/PrismMine.cs b/Projectiles/Ranged/PrismMine.cs index b2e06f1ef6..406e1be8af 100644 --- a/Projectiles/Ranged/PrismMine.cs +++ b/Projectiles/Ranged/PrismMine.cs @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Ranged float rotation = projectile.AngleTo(destination); float remainingDistance = projectile.Distance(destination) - 30f; float laserScale = 0.5f; - Rectangle frame = laserTexture.Frame(1, 7, 0, (int)(Main.GlobalTime * 17f + projectile.identity * 3f) % 7); + Rectangle frame = laserTexture.Frame(1, 7, 0, (int)(Main.GlobalTime * 10f + projectile.identity * 3f) % 7); Vector2 laserOrigin = frame.Size() * 0.5f; while (remainingDistance > frame.Height * laserScale) { diff --git a/Projectiles/Rogue/PrismRocket.cs b/Projectiles/Rogue/PrismRocket.cs index 482518b704..25e8598ab3 100644 --- a/Projectiles/Rogue/PrismRocket.cs +++ b/Projectiles/Rogue/PrismRocket.cs @@ -61,6 +61,9 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i < 2; i++) { + if (!Main.rand.NextBool(3)) + continue; + Dust dust = Dust.NewDustPerfect(projectile.Center - (projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * 10f, 261); dust.color = Color.Cyan; dust.velocity = Main.rand.NextVector2Unit(); diff --git a/Projectiles/Rogue/PrismShurikenBlade.cs b/Projectiles/Rogue/PrismShurikenBlade.cs index 696565eed0..31e90538bb 100644 --- a/Projectiles/Rogue/PrismShurikenBlade.cs +++ b/Projectiles/Rogue/PrismShurikenBlade.cs @@ -31,9 +31,9 @@ namespace CalamityMod.Projectiles.Rogue if (Main.dedServ) return; - for (int i = 0; i < 25; i++) + for (int i = 0; i < 15; i++) { - Vector2 circularOffsetDirection = (MathHelper.TwoPi * i / 25f).ToRotationVector2().RotatedBy(projectile.velocity.ToRotation() - MathHelper.PiOver2); + Vector2 circularOffsetDirection = (MathHelper.TwoPi * i / 15f).ToRotationVector2().RotatedBy(projectile.velocity.ToRotation() - MathHelper.PiOver2); Vector2 spawnPosition = projectile.Center - (projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * projectile.height * 1.25f; spawnPosition += circularOffsetDirection * new Vector2(12f, 7f); diff --git a/Projectiles/Rogue/RefractionRotorProjectile.cs b/Projectiles/Rogue/RefractionRotorProjectile.cs index e87801c161..24cdfaf854 100644 --- a/Projectiles/Rogue/RefractionRotorProjectile.cs +++ b/Projectiles/Rogue/RefractionRotorProjectile.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Rogue // If this projectile is a stealth strike, don't create the blades as a gore-- create them as a projectile instead. if (!Main.dedServ) { - for (int i = 0; i < 80; i++) + for (int i = 0; i < 15; i++) { Dust rainbowBurst = Dust.NewDustPerfect(projectile.Center, 267); rainbowBurst.color = Main.hslToRgb(i / 80f, 0.9f, 0.6f); diff --git a/Projectiles/Summon/BrimstoneDartMinion.cs b/Projectiles/Summon/BrimstoneDartMinion.cs new file mode 100644 index 0000000000..68f0f1acd4 --- /dev/null +++ b/Projectiles/Summon/BrimstoneDartMinion.cs @@ -0,0 +1,58 @@ +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class BrimstoneDartMinion : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Boss/BrimstoneBarrage"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brimfire"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionShot[projectile.type] = true; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 18; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.timeLeft = 300; + projectile.penetrate = 1; + projectile.minion = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.alpha = 255; + } + + public override void AI() + { + projectile.frameCounter++; + projectile.frame = projectile.frameCounter / 5 % Main.projFrames[projectile.type]; + projectile.Opacity = Utils.InverseLerp(300f, 285f, projectile.timeLeft, true) * Utils.InverseLerp(0f, 15f, projectile.timeLeft, true); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (projectile.velocity.Length() < 35f) + projectile.velocity *= 1.036f; + + Lighting.AddLight(projectile.Center, 0.75f, 0f, 0f); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(ModContent.BuffType(), 600); + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor.R = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } +} 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/Projectiles/Summon/SepulcherArm.png b/Projectiles/Summon/SepulcherArm.png new file mode 100644 index 0000000000..b45111f206 Binary files /dev/null and b/Projectiles/Summon/SepulcherArm.png differ diff --git a/Projectiles/Summon/SepulcherForeArm.png b/Projectiles/Summon/SepulcherForeArm.png new file mode 100644 index 0000000000..da24ee8a4f Binary files /dev/null and b/Projectiles/Summon/SepulcherForeArm.png differ diff --git a/Projectiles/Summon/SepulcherHand.png b/Projectiles/Summon/SepulcherHand.png new file mode 100644 index 0000000000..c28935e9f2 Binary files /dev/null and b/Projectiles/Summon/SepulcherHand.png differ diff --git a/Projectiles/Summon/SepulcherMinion.cs b/Projectiles/Summon/SepulcherMinion.cs new file mode 100644 index 0000000000..7635085c33 --- /dev/null +++ b/Projectiles/Summon/SepulcherMinion.cs @@ -0,0 +1,690 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.NPCs.Other; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class SepulcherMinion : ModProjectile + { + public struct SepulcherSegment + { + public Vector2 CurrentPosition; + public float Rotation; + public SepulcherSegment(Vector2 position, float rotation) + { + CurrentPosition = position; + Rotation = rotation; + } + } + + public class SepulcherArm + { + public class SepulcherArmLimb + { + public Vector2 Center; + public float Rotation; + + public SepulcherArmLimb(Vector2 center, float rotation) + { + Center = center; + Rotation = rotation; + } + + public void SendData(BinaryWriter writer) + { + writer.WritePackedVector2(Center); + writer.Write(Rotation); + } + + public static SepulcherArmLimb ReceiveData(BinaryReader reader) => new SepulcherArmLimb(reader.ReadPackedVector2(), reader.ReadSingle()); + } + + public SepulcherArmLimb[] Limbs = new SepulcherArmLimb[2]; + public byte SegmentIndexToAttachTo; + public Vector2 Center; + public float Rotation; + public bool ReelingBack = false; + public bool Direction; + public SepulcherArm(Vector2 center, byte segmentIndexToAttachTo, float rotation, bool reelingBack, bool direction) + { + Center = center; + SegmentIndexToAttachTo = segmentIndexToAttachTo; + Rotation = rotation; + ReelingBack = reelingBack; + Direction = direction; + Limbs = new SepulcherArmLimb[2] + { + new SepulcherArmLimb(center, rotation), + new SepulcherArmLimb(center, rotation) + }; + } + } + + public enum AIState + { + HoverNearOwner, + AttackEnemy_Charge, + AttackEnemy_ReleaseDartBurst, + AttackOwner + } + + public int IdleTimer; + public int AttackTimer; + public int PlayerAttackCountdown; + public SepulcherSegment[] Segments = new SepulcherSegment[24]; + public List Arms = new List(); + public Player Owner => Main.player[projectile.owner]; + public AIState CurrentAIState + { + get => (AIState)(int)projectile.ai[0]; + set + { + // Don't do anything unless the caller is the owner of this projectile- changes will be synced to other clients in MP. + if (Main.myPlayer != projectile.owner) + return; + + projectile.ai[0] = (int)value; + projectile.netUpdate = true; + } + } + public ref float JawRotation => ref projectile.localAI[0]; + public ref float JawSnapTimer => ref projectile.localAI[1]; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sepulcher"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 54; + projectile.height = 54; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.netImportant = true; + projectile.penetrate = -1; + projectile.minionSlots = 4f; + projectile.timeLeft = 90000; + projectile.Opacity = 0f; + projectile.tileCollide = false; + projectile.minion = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 4; + projectile.hide = true; + } + + #region Syncing + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(IdleTimer); + writer.Write(PlayerAttackCountdown); + writer.Write(Arms.Count); + for (int i = 0; i < Arms.Count; i++) + { + writer.WritePackedVector2(Arms[i].Center); + writer.Write(Arms[i].SegmentIndexToAttachTo); + writer.Write(Arms[i].Rotation); + writer.Write(Arms[i].ReelingBack); + writer.Write(Arms[i].Direction); + Arms[0].Limbs[0].SendData(writer); + Arms[0].Limbs[1].SendData(writer); + } + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + IdleTimer = reader.ReadInt32(); + PlayerAttackCountdown = reader.ReadInt32(); + Arms.Clear(); + for (int i = 0; i < reader.ReadInt32(); i++) + { + Arms.Add(new SepulcherArm(reader.ReadPackedVector2(), reader.ReadByte(), reader.ReadSingle(), reader.ReadBoolean(), reader.ReadBoolean())); + Arms.Last().Limbs[0] = SepulcherArm.SepulcherArmLimb.ReceiveData(reader); + Arms.Last().Limbs[1] = SepulcherArm.SepulcherArmLimb.ReceiveData(reader); + } + } + #endregion + + #region AI + public override void AI() + { + Initialize(); + HandleBuffs(); + HandleFlexibleDamage(); + UpdateSegments(); + + // Fade in rapidly. + projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.2f, 0f, 1f); + + NPC potentialTarget = AttemptToFindTarget(1450f); + + // Enter the attack state if a valid enemy is found and go back to hovering otherwise. + // This will be overriden if attacking the owner. + if (CurrentAIState != AIState.AttackEnemy_ReleaseDartBurst && CurrentAIState != AIState.AttackEnemy_Charge) + { + if (potentialTarget != null) + CurrentAIState = AIState.AttackEnemy_ReleaseDartBurst; + } + else if (potentialTarget is null) + { + CurrentAIState = AIState.HoverNearOwner; + AttackTimer = 0; + } + + // Reset the AI to player attack mode if the countdown is going on. + if (PlayerAttackCountdown > 0) + { + if (CurrentAIState != AIState.AttackOwner) + CurrentAIState = AIState.AttackOwner; + + PlayerAttackCountdown--; + + // If it's finished, go back to idle owner hover movement. + if (PlayerAttackCountdown <= 0) + CurrentAIState = AIState.HoverNearOwner; + } + + + // Determine whether the projectile can attack its owner based on the attakc countdown. + projectile.hostile = PlayerAttackCountdown > 0; + + switch (CurrentAIState) + { + case AIState.HoverNearOwner: + HoverNearOwner(); + break; + case AIState.AttackEnemy_ReleaseDartBurst: + AttackEnemyWithDarts(potentialTarget); + AttackTimer++; + break; + case AIState.AttackEnemy_Charge: + AttackEnemyByCharging(potentialTarget); + AttackTimer++; + break; + case AIState.AttackOwner: + AttackOwner(); + break; + } + + // Check if ready to enrage every so often. + IdleTimer++; + if (IdleTimer % 600 == 599) + { + int heartsAttachedToOwner = 0; + int heartType = ModContent.NPCType(); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].type != heartType || !Main.npc[i].active || Main.npc[i].target != projectile.owner) + continue; + heartsAttachedToOwner++; + } + + float chanceToBecomeAngry = 0f; + if (heartsAttachedToOwner >= 2) + chanceToBecomeAngry = Utils.InverseLerp(2f, 6f, heartsAttachedToOwner, true); + if (Main.rand.NextFloat() < chanceToBecomeAngry) + { + PlayerAttackCountdown = 300; + projectile.netUpdate = true; + } + else if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC((int)Owner.Center.X, (int)Owner.Center.Y, heartType); + } + + if (JawSnapTimer > 0f) + { + JawRotation = JawRotation.AngleTowards(-0.44f, 0.064f); + JawSnapTimer--; + } + else + JawRotation = JawRotation.AngleTowards(0f, 0.03f); + } + + public void Initialize() + { + if (projectile.ai[1] != 0f) + return; + + for (int i = 0; i < Segments.Length; i++) + Segments[i].CurrentPosition = projectile.Center - projectile.velocity.SafeNormalize(Vector2.UnitY) * i * 0.2f; + + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + projectile.ai[1] = 1f; + if (Main.myPlayer == projectile.owner) + { + float rotationalOffset = 0f; + for (byte i = 3; i < Segments.Length - 2; i += 2) + { + Arms.Add(new SepulcherArm(Segments[i].CurrentPosition, i, rotationalOffset, false, false)); + rotationalOffset = MathHelper.WrapAngle(rotationalOffset + MathHelper.Pi / 6f); + + Arms.Add(new SepulcherArm(Segments[i].CurrentPosition, i, rotationalOffset + MathHelper.Pi, false, true)); + rotationalOffset = MathHelper.WrapAngle(rotationalOffset + MathHelper.Pi / 6f); + } + projectile.netUpdate = true; + } + } + + public void HandleBuffs() + { + // Maintain or remove the Mechworm buff from the owner. + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Owner.dead) + Owner.Calamity().sepulcher = false; + if (Owner.Calamity().sepulcher) + projectile.timeLeft = 2; + } + + public void HandleFlexibleDamage() + { + // Adjust the damage of this projectile if the owner's current minion damage factor has changed for any reason. + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * Owner.MinionDamage()); + projectile.damage = trueDamage; + } + } + + public void UpdateSegments() + { + float aheadRotation = projectile.rotation; + Vector2 aheadPosition = projectile.Center; + + // Connect all segments to each-other and calculate their rotations. + for (int i = 0; i < Segments.Length; i++) + { + Vector2 offsetToDestination = aheadPosition - Segments[i].CurrentPosition; + // This variant of segment attachment incorporates rotation. + // Given the fact that all segments will execute this code is succession, the + // result across the entire worm will exponentially decay over each segment, + // allowing for smooth rotations. This code is what the stardust dragon uses for its segmenting. + if (aheadRotation != Segments[i].Rotation) + { + float angleOffset = MathHelper.WrapAngle(aheadRotation - Segments[i].Rotation.AngleLerp(aheadRotation, 0.08f)); + offsetToDestination = offsetToDestination.RotatedBy(angleOffset * 0.08f); + } + + Segments[i].Rotation = (aheadPosition - Segments[i].CurrentPosition).ToRotation() + MathHelper.PiOver2; + Segments[i].CurrentPosition = aheadPosition - offsetToDestination.SafeNormalize(Vector2.Zero) * 48f; + + // Adjust the ahead positions before interating further. + aheadPosition = Segments[i].CurrentPosition; + aheadRotation = Segments[i].Rotation; + } + + // Adjust the arms. + for (int i = 0; i < Arms.Count; i++) + { + SepulcherSegment segmentToAttachTo = Segments[Arms[i].SegmentIndexToAttachTo]; + Vector2 idealMovePosition = segmentToAttachTo.CurrentPosition; + float sideFactor = MathHelper.Lerp(200f, 18f, Utils.InverseLerp(-0.51f, -0.06f, Arms[i].Rotation, true)); + float aheadFactor = MathHelper.Lerp(284f, 680f, Utils.InverseLerp(-0.51f, -0.06f, Arms[i].Rotation, true)); + int direction = Arms[i].Direction.ToDirectionInt(); + idealMovePosition += (segmentToAttachTo.Rotation + Arms[i].Rotation * direction - MathHelper.PiOver2).ToRotationVector2() * projectile.scale * aheadFactor; + idealMovePosition += (segmentToAttachTo.Rotation + Arms[i].Rotation * direction - MathHelper.PiOver2 + MathHelper.PiOver2 * direction).ToRotationVector2() * projectile.scale * sideFactor; + Arms[i].Center = idealMovePosition; + + Vector2 offsetFromSegment = Vector2.Zero; + + offsetFromSegment += new Vector2(direction * 35f, 28f).RotatedBy(segmentToAttachTo.Rotation - (MathHelper.PiOver2 - Arms[i].Rotation * 1.7f - 0.77f) * direction).SafeNormalize(Vector2.UnitY) * 62f; + Arms[i].Limbs[0].Center = segmentToAttachTo.CurrentPosition + offsetFromSegment; + Arms[i].Limbs[0].Rotation = offsetFromSegment.ToRotation(); + + Arms[i].Limbs[1].Rotation = (Arms[i].Center - Arms[i].Limbs[0].Center).ToRotation(); + Arms[i].Limbs[1].Center = Arms[i].Limbs[0].Center + offsetFromSegment * 0.5f + (Arms[i].Center - Arms[i].Limbs[0].Center).SafeNormalize(Vector2.UnitY) * 64f; + + float rotationalVelocityFactor = Utils.InverseLerp(0f, 6f, projectile.velocity.Length(), true); + if (CurrentAIState == AIState.AttackEnemy_Charge) + rotationalVelocityFactor *= 0.85f; + if (CurrentAIState == AIState.AttackOwner) + rotationalVelocityFactor *= 1.2f; + + if (Arms[i].ReelingBack) + { + Arms[i].Rotation -= rotationalVelocityFactor * 0.066f; + if (Arms[i].Rotation < -0.55f) + Arms[i].ReelingBack = false; + } + else + { + Arms[i].Rotation += rotationalVelocityFactor * 0.029f; + if (Arms[i].Rotation > 0.77f) + Arms[i].ReelingBack = true; + } + } + } + + public void HoverNearOwner() + { + // Teleport to the owner if it's very far away. + if (!projectile.WithinRange(Owner.Center, 3200f)) + { + projectile.Center = Owner.Center; + projectile.velocity = Main.rand.NextVector2CircularEdge(4f, 4f); + projectile.netUpdate = true; + } + + // Attempt to move towards the owner. + if (!projectile.WithinRange(Owner.Center, 540f)) + { + Vector2 destination = Owner.Center + (IdleTimer / 31f).ToRotationVector2() * 240f; + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(destination) * 18f, 0.03f); + + float updatedDirectionRotation = projectile.velocity.ToRotation().AngleTowards(projectile.AngleTo(destination), 0.04f); + projectile.velocity = updatedDirectionRotation.ToRotationVector2() * projectile.velocity.Length(); + } + else if (projectile.velocity.Length() < 16f) + projectile.velocity *= 1.03f; + + // Determine the head rotation. + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + + public void AttackEnemyWithDarts(NPC target) + { + Vector2 destination = target.Center + ((AttackTimer / 20f).ToRotationVector2() * 320f); + + // Step towards the ideal velocity with an acceleration of 1 pixel/second^2. + projectile.velocity = projectile.velocity.MoveTowards(projectile.SafeDirectionTo(destination) * 24f, 1f); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + // Release a burst of darts from all segments at the target. + if (Main.myPlayer == projectile.owner && AttackTimer % 60 > 60 - Segments.Length) + { + int segmentToFireFrom = 60 - AttackTimer % 60; + Vector2 spawnPosition = Segments[segmentToFireFrom].CurrentPosition; + Vector2 shootVelocity = (target.Center - spawnPosition).SafeNormalize(Vector2.UnitY) * 8f; + Projectile.NewProjectile(spawnPosition, shootVelocity, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack, projectile.owner); + } + + if (Main.myPlayer == projectile.owner && AttackTimer > 430) + { + CurrentAIState = AIState.AttackEnemy_Charge; + AttackTimer = 0; + } + } + + public void AttackEnemyByCharging(NPC target) + { + if (!projectile.WithinRange(target.Center, 350f)) + { + Vector2 destination = target.Center + (AttackTimer / 25f).ToRotationVector2() * MathHelper.Min(target.width * 0.35f, 150f); + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(destination) * 34f, 0.08f); + + float updatedDirectionRotation = projectile.velocity.ToRotation().AngleTowards(projectile.AngleTo(destination), 0.12f); + projectile.velocity = updatedDirectionRotation.ToRotationVector2() * projectile.velocity.Length(); + } + else if (projectile.velocity.Length() < 29f) + { + projectile.velocity *= 1.035f; + if (JawSnapTimer <= 0f) + { + // Open the mouth of the jaw if close but not super close to the target. + if (projectile.WithinRange(target.Center, 270f)) + JawRotation = JawRotation.AngleLerp(0.87f, 0.12f); + + // If really close, snap. + if (projectile.WithinRange(target.Center, 165f)) + { + Main.PlaySound(SoundID.DD2_SkeletonHurt, projectile.Center); + JawSnapTimer = 45f; + } + } + } + + // Determine the head rotation. + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (Main.myPlayer == projectile.owner && AttackTimer > 480) + { + CurrentAIState = AIState.AttackEnemy_ReleaseDartBurst; + AttackTimer = 0; + } + } + + public void AttackOwner() + { + // Attempt to angle towards the owner. + float newSpeed = MathHelper.Lerp(projectile.velocity.Length(), 21f, 0.025f); + + if (!projectile.WithinRange(Owner.Center, 370f)) + { + Vector2 idealVelocity = projectile.SafeDirectionTo(Owner.Center) * newSpeed; + projectile.velocity = projectile.velocity.MoveTowards(idealVelocity, 2f); + + float idealAimDirection = idealVelocity.ToRotation(); + projectile.velocity = projectile.velocity.ToRotation().AngleLerp(idealAimDirection, 0.05f).ToRotationVector2() * projectile.velocity.Length(); + } + else if (projectile.velocity.Length() < 36f) + { + projectile.velocity *= 1.03f; + if (JawSnapTimer <= 0f) + { + // Open the mouth of the jaw if close but not super close to the owner. + if (projectile.WithinRange(Owner.Center, 300f)) + JawRotation = JawRotation.AngleLerp(0.87f, 0.12f); + + // If really close, snap. + if (projectile.WithinRange(Owner.Center, 180f)) + { + Main.PlaySound(SoundID.DD2_SkeletonHurt, projectile.Center); + JawSnapTimer = 45f; + } + } + } + + // Determine the head rotation. + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + + public NPC AttemptToFindTarget(float searchDistance) + { + NPC closestTarget = null; + + int heartType = ModContent.NPCType(); + if (Owner.HasMinionAttackTargetNPC) + { + NPC targetedNPC = Main.npc[Owner.MinionAttackTargetNPC]; + if (targetedNPC.WithinRange(projectile.Center, searchDistance) && targetedNPC.CanBeChasedBy() && targetedNPC.type != heartType) + return targetedNPC; + } + + float distance = searchDistance * searchDistance; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy() && Main.npc[i].type != heartType) + { + float extraDistance = (Main.npc[i].width / 2) + (Main.npc[i].height / 2); + + if (Main.npc[i].WithinRange(projectile.Center, distance + extraDistance)) + { + distance = Main.npc[i].DistanceSQ(projectile.Center); + closestTarget = Main.npc[i]; + } + } + } + + return closestTarget; + } + + #endregion + + #region Drawing + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + float angerFactor = Utils.InverseLerp(300f, 280f, PlayerAttackCountdown, true) * Utils.InverseLerp(0f, 30f, PlayerAttackCountdown, true); + float afterimageOutwardness = MathHelper.Lerp(6f, 8f, (float)Math.Cos(Main.GlobalTime * 2.3f) * 0.5f + 0.5f) * angerFactor; + Color backAfterimageColor = Color.Red * angerFactor; + backAfterimageColor.A = 0; + + Texture2D eyesTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherMinionEyes"); + Texture2D jawTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherMinionJaw"); + Texture2D headTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherMinionHead"); + Texture2D bodyTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherMinionBody"); + Texture2D bodyTexture2 = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherMinionBodyAlt"); + Texture2D tailTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherMinionTail"); + Texture2D armTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherArm"); + Texture2D foreArmTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherForeArm"); + Texture2D handTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/SepulcherHand"); + + Vector2 drawPosition; + + // Draw the arms. + for (int i = 0; i < Arms.Count; i++) + { + Vector2 forearmDrawPosition = Arms[i].Limbs[0].Center - Main.screenPosition; + Color drawColor = Lighting.GetColor((int)(Arms[i].Limbs[0].Center.X / 16), (int)(Arms[i].Limbs[0].Center.Y / 16)); + + if (afterimageOutwardness > 0f) + { + for (int j = 0; j < 4; j++) + { + Vector2 drawOffset = (MathHelper.TwoPi * j / 4f).ToRotationVector2() * afterimageOutwardness; + spriteBatch.Draw(foreArmTexture, forearmDrawPosition + drawOffset, null, backAfterimageColor, Arms[i].Limbs[0].Rotation + MathHelper.PiOver2, foreArmTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + } + spriteBatch.Draw(foreArmTexture, forearmDrawPosition, null, drawColor, Arms[i].Limbs[0].Rotation + MathHelper.PiOver2, foreArmTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + + Vector2 armDrawPosition = Arms[i].Limbs[1].Center - Main.screenPosition; + drawColor = Lighting.GetColor((int)(Arms[i].Limbs[1].Center.X / 16), (int)(Arms[i].Limbs[1].Center.Y / 16)); + + if (afterimageOutwardness > 0f) + { + for (int j = 0; j < 4; j++) + { + Vector2 drawOffset = (MathHelper.TwoPi * j / 4f).ToRotationVector2() * afterimageOutwardness; + spriteBatch.Draw(armTexture, armDrawPosition + drawOffset, null, backAfterimageColor, Arms[i].Limbs[1].Rotation + MathHelper.PiOver2, armTexture.Size() * new Vector2(0.5f, 0f), projectile.scale, SpriteEffects.FlipVertically, 0f); + } + } + spriteBatch.Draw(armTexture, armDrawPosition, null, drawColor, Arms[i].Limbs[1].Rotation + MathHelper.PiOver2, armTexture.Size() * new Vector2(0.5f, 0f), projectile.scale, SpriteEffects.FlipVertically, 0f); + + Vector2 handDrawPosition = armDrawPosition; + SpriteEffects handDirection = Arms[i].Direction ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + if (afterimageOutwardness > 0f) + { + for (int j = 0; j < 4; j++) + { + Vector2 drawOffset = (MathHelper.TwoPi * j / 4f).ToRotationVector2() * afterimageOutwardness; + spriteBatch.Draw(handTexture, handDrawPosition + drawOffset, null, backAfterimageColor, Arms[i].Limbs[1].Rotation - MathHelper.PiOver2, handTexture.Size() * new Vector2(0.5f, 0f), projectile.scale, handDirection, 0f); + } + } + spriteBatch.Draw(handTexture, handDrawPosition, null, drawColor, Arms[i].Limbs[1].Rotation - MathHelper.PiOver2, handTexture.Size() * new Vector2(0.5f, 0f), projectile.scale, handDirection, 0f); + } + + // Draw the segments. + for (int i = 0; i < Segments.Length; i++) + { + Texture2D textureToUse = i % 2 == 1 ? bodyTexture2 : bodyTexture; + + // Use the tail texture for the last segment. + if (i == Segments.Length - 1) + textureToUse = tailTexture; + + drawPosition = Segments[i].CurrentPosition - Main.screenPosition; + lightColor = Lighting.GetColor((int)(drawPosition.X + Main.screenPosition.X) / 16, (int)(drawPosition.Y + Main.screenPosition.Y) / 16); + + if (afterimageOutwardness > 0f) + { + for (int j = 0; j < 4; j++) + { + Vector2 drawOffset = (MathHelper.TwoPi * j / 4f).ToRotationVector2() * afterimageOutwardness; + spriteBatch.Draw(textureToUse, drawPosition + drawOffset, null, backAfterimageColor, Segments[i].Rotation, textureToUse.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + } + spriteBatch.Draw(textureToUse, drawPosition, null, projectile.GetAlpha(lightColor), Segments[i].Rotation, textureToUse.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + + drawPosition = projectile.Center - Main.screenPosition; + lightColor = Lighting.GetColor((int)(drawPosition.X + Main.screenPosition.X) / 16, (int)(drawPosition.Y + Main.screenPosition.Y) / 16); + + // Draw the jaws. + for (int i = -1; i <= 1; i += 2) + { + float jawBaseOffset = 24f; + SpriteEffects jawSpriteEffect = i == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 jawPosition = projectile.Center - Main.screenPosition; + jawPosition += Vector2.UnitX.RotatedBy(projectile.rotation + JawRotation * i) * i * (jawBaseOffset + (float)Math.Sin(JawRotation) * 14f); + jawPosition -= Vector2.UnitY.RotatedBy(projectile.rotation) * (26f + (float)Math.Sin(JawRotation) * 8f); + spriteBatch.Draw(jawTexture, jawPosition, null, projectile.GetAlpha(lightColor), projectile.rotation + JawRotation * i, jawTexture.Size() * 0.5f, projectile.scale * 1.25f, jawSpriteEffect, 0f); + } + + // Draw the head. + if (afterimageOutwardness > 0f) + { + for (int i = 0; i < 4; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * afterimageOutwardness; + spriteBatch.Draw(headTexture, drawPosition + drawOffset, null, backAfterimageColor, projectile.rotation, headTexture.Size() * 0.5f, projectile.scale * 1.25f, SpriteEffects.None, 0f); + } + } + spriteBatch.Draw(headTexture, drawPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, headTexture.Size() * 0.5f, projectile.scale * 1.25f, SpriteEffects.None, 0f); + + // Draw demonic eyes if enraged. + if (afterimageOutwardness > 0f) + { + for (int i = 0; i < (int)(projectile.oldPos.Length * angerFactor); i++) + { + drawPosition = projectile.Center - Main.screenPosition - projectile.velocity.SafeNormalize(Vector2.Zero) * 3f * i; + Color fadeColor = Color.White * (1f - i / (float)projectile.oldPos.Length); + spriteBatch.Draw(eyesTexture, drawPosition, null, projectile.GetAlpha(fadeColor), projectile.oldRot[i], eyesTexture.Size() * 0.5f, projectile.scale * 1.25f, SpriteEffects.None, 0f); + } + } + + return false; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // If default collision is possible return true immediately. + if (projHitbox.Intersects(targetHitbox)) + return true; + + // Check based on segments. + for (int i = 0; i < Segments.Length; i++) + { + if (Utils.CenteredRectangle(Segments[i].CurrentPosition, Vector2.One * 52f).Intersects(targetHitbox)) + return true; + } + + return false; + } + + public override void DrawBehind(int index, List drawCacheProjsBehindNPCsAndTiles, List drawCacheProjsBehindNPCs, List drawCacheProjsBehindProjectiles, List drawCacheProjsOverWiresUI) + { + drawCacheProjsBehindProjectiles.Add(index); + } + + #endregion + + #region Damage Stuff + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + damage = Main.rand.Next(80, 90); + } + + public override bool? CanHitNPC(NPC target) + { + if (target.type == ModContent.NPCType()) + return false; + return null; + } + #endregion + } +} diff --git a/Projectiles/Summon/SepulcherMinionBody.png b/Projectiles/Summon/SepulcherMinionBody.png new file mode 100644 index 0000000000..5e8b75333e Binary files /dev/null and b/Projectiles/Summon/SepulcherMinionBody.png differ diff --git a/Projectiles/Summon/SepulcherMinionBodyAlt.png b/Projectiles/Summon/SepulcherMinionBodyAlt.png new file mode 100644 index 0000000000..7bddb6f35e Binary files /dev/null and b/Projectiles/Summon/SepulcherMinionBodyAlt.png differ diff --git a/Projectiles/Summon/SepulcherMinionEyes.png b/Projectiles/Summon/SepulcherMinionEyes.png new file mode 100644 index 0000000000..29f5267031 Binary files /dev/null and b/Projectiles/Summon/SepulcherMinionEyes.png differ diff --git a/Projectiles/Summon/SepulcherMinionHead.png b/Projectiles/Summon/SepulcherMinionHead.png new file mode 100644 index 0000000000..e1fb445359 Binary files /dev/null and b/Projectiles/Summon/SepulcherMinionHead.png differ diff --git a/Projectiles/Summon/SepulcherMinionJaw.png b/Projectiles/Summon/SepulcherMinionJaw.png new file mode 100644 index 0000000000..11df3bb5ae Binary files /dev/null and b/Projectiles/Summon/SepulcherMinionJaw.png differ diff --git a/Projectiles/Summon/SepulcherMinionTail.png b/Projectiles/Summon/SepulcherMinionTail.png new file mode 100644 index 0000000000..283e094283 Binary files /dev/null and b/Projectiles/Summon/SepulcherMinionTail.png differ diff --git a/Projectiles/Summon/SummonBrimstoneExplosion.cs b/Projectiles/Summon/SummonBrimstoneExplosion.cs new file mode 100644 index 0000000000..0c4eb00e90 --- /dev/null +++ b/Projectiles/Summon/SummonBrimstoneExplosion.cs @@ -0,0 +1,72 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class SummonBrimstoneExplosion : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Explosion"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + Main.projFrames[projectile.type] = 6; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 160; + projectile.friendly = true; + projectile.hostile = true; + projectile.minion = true; + projectile.penetrate = -1; + projectile.timeLeft = Main.projFrames[projectile.type] * 5; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } + + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + CreateInitialDust(); + projectile.localAI[0] = 1f; + } + + // Emit crimson light. + Lighting.AddLight(projectile.Center, Color.Red.ToVector3() * 1.1f); + if (projectile.timeLeft % 5f == 4f) + projectile.frame++; + } + + public void CreateInitialDust() + { + float randomnessSmoothness = 3f; + for (int i = 0; i < 10; i++) + { + randomnessSmoothness += i; + + int offsetVariance = (int)(randomnessSmoothness * 4f); + for (int j = 0; j < 30; j++) + { + Vector2 velocity = Main.rand.NextVector2Square(-randomnessSmoothness, randomnessSmoothness).SafeNormalize(Vector2.UnitY) * randomnessSmoothness * 0.48f; + Dust dust = Dust.NewDustDirect(projectile.Center, offsetVariance, offsetVariance, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.6f); + dust.position += Main.rand.NextVector2Square(-10f, 10f); + dust.velocity = velocity; + dust.noGravity = true; + } + } + + projectile.Damage(); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 48); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + // Prevent absurd quantities of damage to the player. + damage = (int)(damage * 0.018); + } + } +} diff --git a/Projectiles/Summon/SummonBrimstoneExplosion.png b/Projectiles/Summon/SummonBrimstoneExplosion.png new file mode 100644 index 0000000000..b53b2fea88 Binary files /dev/null and b/Projectiles/Summon/SummonBrimstoneExplosion.png differ diff --git a/Projectiles/Summon/SummonBrimstoneExplosionSmall.cs b/Projectiles/Summon/SummonBrimstoneExplosionSmall.cs new file mode 100644 index 0000000000..24b4b6de0e --- /dev/null +++ b/Projectiles/Summon/SummonBrimstoneExplosionSmall.cs @@ -0,0 +1,64 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class SummonBrimstoneExplosionSmall : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Explosion"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + Main.projFrames[projectile.type] = 6; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 108; + projectile.friendly = true; + projectile.hostile = false; + projectile.minion = true; + projectile.penetrate = -1; + projectile.timeLeft = Main.projFrames[projectile.type] * 5; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } + + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + CreateInitialDust(); + projectile.localAI[0] = 1f; + } + + // Emit crimson light. + Lighting.AddLight(projectile.Center, Color.Red.ToVector3() * 1.1f); + if (projectile.timeLeft % 5f == 4f) + projectile.frame++; + } + + public void CreateInitialDust() + { + float randomnessSmoothness = 3f; + for (int i = 0; i < 6; i++) + { + randomnessSmoothness += i * 0.36f; + + for (int j = 0; j < 30; j++) + { + Vector2 velocity = Main.rand.NextVector2Square(-randomnessSmoothness, randomnessSmoothness).SafeNormalize(Vector2.UnitY) * randomnessSmoothness * 0.48f; + Dust dust = Dust.NewDustDirect(projectile.position + Vector2.One * 22f, 1, 1, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.6f); + dust.position += Main.rand.NextVector2Square(-10f, 10f); + dust.velocity = velocity; + dust.noGravity = true; + } + } + + projectile.Damage(); + } + } +} diff --git a/Projectiles/Summon/SummonBrimstoneExplosionSmall.png b/Projectiles/Summon/SummonBrimstoneExplosionSmall.png new file mode 100644 index 0000000000..b53b2fea88 Binary files /dev/null and b/Projectiles/Summon/SummonBrimstoneExplosionSmall.png differ diff --git a/Projectiles/Typeless/SuicideBomberDemon.cs b/Projectiles/Typeless/SuicideBomberDemon.cs new file mode 100644 index 0000000000..a712fd1b16 --- /dev/null +++ b/Projectiles/Typeless/SuicideBomberDemon.cs @@ -0,0 +1,117 @@ +using Microsoft.Xna.Framework; +using System.IO; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class SuicideBomberDemon : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Demon"); + Main.projFrames[projectile.type] = 5; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 32; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 5; + projectile.Opacity = 0f; + projectile.timeLeft = 300; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.friendly); + writer.Write(projectile.hostile); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.friendly = reader.ReadBoolean(); + projectile.hostile = reader.ReadBoolean(); + } + + public override void AI() + { + if (projectile.owner == 255) + projectile.owner = Player.FindClosest(projectile.Center, 1, 1); + projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.025f, 0f, 1f); + + projectile.frame = projectile.frameCounter++ / 5 % Main.projFrames[projectile.type]; + + // Anti-clumping behavior. + float pushForce = 0.08f; + for (int k = 0; k < Main.maxProjectiles; k++) + { + Projectile otherProj = Main.projectile[k]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || otherProj.type != projectile.type || k == projectile.whoAmI) + continue; + + // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. + bool sameProjType = otherProj.type == projectile.type; + float taxicabDist = MathHelper.Distance(projectile.position.X, otherProj.position.X) + MathHelper.Distance(projectile.position.Y, otherProj.position.Y); + if (sameProjType && taxicabDist < 60f) + { + if (projectile.position.X < otherProj.position.X) + projectile.velocity.X -= pushForce; + else + projectile.velocity.X += pushForce; + + if (projectile.position.Y < otherProj.position.Y) + projectile.velocity.Y -= pushForce; + else + projectile.velocity.Y += pushForce; + } + } + + if (projectile.hostile) + { + projectile.velocity = projectile.velocity.MoveTowards(projectile.SafeDirectionTo(Owner.Center) * 16f, 1.4f); + projectile.spriteDirection = (Owner.Center.X > projectile.Center.X).ToDirectionInt(); + if (projectile.Hitbox.Intersects(Owner.Hitbox)) + projectile.Kill(); + } + else if (projectile.friendly) + { + NPC potentialTarget = projectile.Center.ClosestNPCAt(1360f); + if (potentialTarget is null) + projectile.velocity = Vector2.Lerp(projectile.velocity, -Vector2.UnitY * 10f, 0.06f); + else + { + projectile.spriteDirection = (potentialTarget.Center.X > projectile.Center.X).ToDirectionInt(); + projectile.velocity = projectile.velocity.MoveTowards(projectile.SafeDirectionTo(potentialTarget.Center) * 18.5f, 3f); + if (projectile.Hitbox.Intersects(potentialTarget.Hitbox)) + { + projectile.Damage(); + projectile.Kill(); + } + } + } + } + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 40; i++) + { + Dust explosion = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 267); + explosion.velocity = Main.rand.NextVector2Circular(4f, 4f); + explosion.color = Color.Red; + explosion.scale = 1.35f; + explosion.fadeIn = 0.45f; + explosion.noGravity = true; + } + } + + public override bool CanDamage() => projectile.Opacity >= 1f; + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) => damage = Main.rand.Next(60, 70); + } +} diff --git a/Projectiles/Typeless/SuicideBomberDemon.png b/Projectiles/Typeless/SuicideBomberDemon.png new file mode 100644 index 0000000000..bd3a5924ca Binary files /dev/null and b/Projectiles/Typeless/SuicideBomberDemon.png differ diff --git a/TrailGeneration/PrimitiveTrail.cs b/TrailGeneration/PrimitiveTrail.cs index 789f726bf6..44754a9700 100644 --- a/TrailGeneration/PrimitiveTrail.cs +++ b/TrailGeneration/PrimitiveTrail.cs @@ -42,6 +42,9 @@ namespace CalamityMod public MiscShaderData SpecialShader; public TrailPointRetrievalFunction TrailPointFunction; + public Vector2 OverridingStickPointStart = Vector2.Zero; + public Vector2 OverridingStickPointEnd = Vector2.Zero; + public delegate List TrailPointRetrievalFunction(IEnumerable originalPositions, Vector2 generalOffset, int totalTrailPoints, IEnumerable originalRotations = null); public PrimitiveTrail(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, TrailPointRetrievalFunction pointFunction = null, MiscShaderData specialShader = null) @@ -93,7 +96,7 @@ namespace CalamityMod BaseEffect.Projection = effectProjection; } - public static List RigidPointRetreivalFunction(IEnumerable originalPositions, Vector2 generalOffset, int totalTrailPoints, IEnumerable originalRotations = null) + public static List RigidPointRetreivalFunction(IEnumerable originalPositions, Vector2 generalOffset, int totalTrailPoints, IEnumerable _ = null) { List basePoints = originalPositions.Where(originalPosition => originalPosition != Vector2.Zero).ToList(); List endPoints = new List(); @@ -191,11 +194,19 @@ namespace CalamityMod // This doesn't use RotatedBy for the sake of performance (there can potentially be a lot of trail points). Vector2 sideDirection = new Vector2(-directionToAhead.Y, directionToAhead.X); + Vector2 left = currentPosition - sideDirection * widthAtVertex; + Vector2 right = currentPosition + sideDirection * widthAtVertex; + if (i == 0 && OverridingStickPointStart != Vector2.Zero) + { + left = OverridingStickPointStart; + right = OverridingStickPointEnd; + } + // What this is doing, at its core, is defining a rectangle based on two triangles. // These triangles are defined based on the width of the strip at that point. // The resulting rectangles combined are what make the trail itself. - vertices[i * 2] = new VertexPosition2DColor(currentPosition - sideDirection * widthAtVertex, vertexColor, leftCurrentTextureCoord); - vertices[i * 2 + 1] = new VertexPosition2DColor(currentPosition + sideDirection * widthAtVertex, vertexColor, rightCurrentTextureCoord); + vertices[i * 2] = new VertexPosition2DColor(left, vertexColor, leftCurrentTextureCoord); + vertices[i * 2 + 1] = new VertexPosition2DColor(right, vertexColor, rightCurrentTextureCoord); } return vertices.ToArray(); diff --git a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs new file mode 100644 index 0000000000..39ade9da0c --- /dev/null +++ b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs @@ -0,0 +1,406 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.UI; +using Terraria.UI.Chat; + +namespace CalamityMod.UI.CalamitasEnchants +{ + public class CalamitasEnchantUI + { + public static int NPCIndex = -1; + public static int EnchantIndex = 0; + public static Enchantment? SelectedEnchantment = null; + public static Item CurrentlyHeldItem = new Item(); + public static float TopButtonClickCountdown = 0f; + public static float BottomButtonClickCountdown = 0f; + public static float ReforgeButtonClickCountdown = 0f; + + public static bool CurrentlyViewing = false; + + public static readonly Vector2 ReforgeUITopLeft = new Vector2(68f, 320f); + public static readonly float ResolutionRatio = Main.screenHeight / 1440f; + + public static Rectangle MouseScreenArea => Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); + + public static bool InRangeOfNPC() + { + // Don't bother trying if no valid NPC has been selected yet. + if (!Main.npc.IndexInRange(NPCIndex) || !Main.npc[NPCIndex].active) + return false; + + Rectangle validTalkArea = Utils.CenteredRectangle(Main.LocalPlayer.Center, new Vector2(Player.tileRangeX * 2f, Player.tileRangeY) * 16f); + return validTalkArea.Intersects(Main.npc[NPCIndex].Hitbox); + } + + public static void Draw(SpriteBatch spriteBatch) + { + // Decrement click cooldowns. + // This is done so that click textures do not instantly disappear. + if (TopButtonClickCountdown > 0f) + TopButtonClickCountdown--; + if (BottomButtonClickCountdown > 0f) + BottomButtonClickCountdown--; + if (ReforgeButtonClickCountdown > 0f) + ReforgeButtonClickCountdown--; + + // Don't bother doing anything except resetting if not looking at the UI. + if (!CurrentlyViewing) + { + // If an item was stored, release it back into the world. + if (!CurrentlyHeldItem.IsAir) + { + Main.LocalPlayer.QuickSpawnClonedItem(CurrentlyHeldItem, CurrentlyHeldItem.stack); + CurrentlyHeldItem.TurnToAir(); + } + + EnchantIndex = 0; + NPCIndex = -1; + return; + } + + // Check if the player can still be in the UI. + if (Main.LocalPlayer.chest != -1 || Main.LocalPlayer.sign != -1 || Main.LocalPlayer.talkNPC == -1 || !Main.playerInventory || !InRangeOfNPC() || Main.InGuideCraftMenu) + { + CurrentlyViewing = false; + + // Check if the player has any items being held. + // If they do, drop it onto the ground. + Main.LocalPlayer.dropItemCheck(); + + // Reload visible recipes in case the dropped item was an ingredient. + Recipe.FindRecipes(); + return; + } + + // Open the inventory and stop talking to any NPCs by default while the UI is open, similar to the goblin tinkerer. + Main.playerInventory = true; + Main.npcChatText = string.Empty; + + Texture2D backgroundTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseBackground"); + Vector2 backgroundScale = Vector2.One * Main.UIScale; + + // Draw the background. + spriteBatch.Draw(backgroundTexture, ReforgeUITopLeft, null, Color.White, 0f, Vector2.Zero, backgroundScale, SpriteEffects.None, 0f); + + // Prevent the player from say, firing a weapon while the mouse is hovering over the UI. + DisableMouseWhenOverUI(backgroundTexture, backgroundScale); + + // Select the enchantment to use. + IEnumerable possibleEnchantments = SelectEnchantment(); + + // Draw the cost and description. + int cost = 0; + if (SelectedEnchantment.HasValue) + { + Point costDrawPositionTopLeft = (ReforgeUITopLeft + new Vector2(50f, 78f) * backgroundScale).ToPoint(); + cost = DrawEnchantmentCost(spriteBatch, costDrawPositionTopLeft); + Point descriptionDrawPositionTopLeft = costDrawPositionTopLeft; + descriptionDrawPositionTopLeft.Y += (int)(Main.UIScale * 70f); + Vector2 iconDrawPositionTopLeft = costDrawPositionTopLeft.ToVector2() + new Vector2(270f, -24f) * Main.UIScale; + + DrawEnchantmentDescription(spriteBatch, descriptionDrawPositionTopLeft); + if (!string.IsNullOrEmpty(SelectedEnchantment.Value.IconTexturePath)) + { + Texture2D iconTexture = ModContent.GetTexture(SelectedEnchantment.Value.IconTexturePath); + DrawIcon(spriteBatch, iconDrawPositionTopLeft, iconTexture); + } + } + + // Draw the item icon. + Vector2 itemSlotDrawPosition = ReforgeUITopLeft + new Vector2(30f, 50f) * backgroundScale; + Vector2 reforgeIconDrawPosition = ReforgeUITopLeft + new Vector2(84f, 60f) * backgroundScale; + DrawItemIcon(spriteBatch, itemSlotDrawPosition, reforgeIconDrawPosition, backgroundScale, out bool isHoveringOverItemIcon, out bool isHoveringOverReforgeIcon); + if (isHoveringOverItemIcon) + InteractWithItemSlot(); + + // Draw the buttons. + DrawAndInteractWithButtons(spriteBatch, possibleEnchantments, ReforgeUITopLeft + new Vector2(210f, 50f) * backgroundScale, ReforgeUITopLeft + new Vector2(210f, 90f) * backgroundScale, backgroundScale); + + // Draw the enchantment name. + if (SelectedEnchantment.HasValue) + DrawEnchantmentName(spriteBatch, ReforgeUITopLeft + new Vector2(216f, 66f) * backgroundScale); + + // Handle spending logic. + if (isHoveringOverReforgeIcon) + { + if (Main.mouseLeft && Main.mouseLeftRelease) + { + InteractWithEnchantIcon(cost); + ReforgeButtonClickCountdown = 15f; + } + } + } + + public static void DisableMouseWhenOverUI(Texture2D backgroundTexture, Vector2 backgroundScale) + { + Rectangle backgroundArea = new Rectangle((int)ReforgeUITopLeft.X, (int)ReforgeUITopLeft.Y, (int)(backgroundTexture.Width * backgroundScale.X), (int)(backgroundTexture.Width * backgroundScale.Y)); + + if (MouseScreenArea.Intersects(backgroundArea)) + { + Main.LocalPlayer.mouseInterface = false; + Main.blockMouse = true; + } + } + + public static IEnumerable SelectEnchantment() + { + IEnumerable possibleEnchantments = EnchantmentManager.GetValidEnchantmentsForItem(CurrentlyHeldItem); + + // Select the enchantment based on an index in the possible enchantments. + // If no possible enchantments were found, default to null. + SelectedEnchantment = null; + + if (possibleEnchantments.Count() > 0) + SelectedEnchantment = possibleEnchantments.ElementAt(EnchantIndex); + + return possibleEnchantments; + } + + public static int DrawEnchantmentCost(SpriteBatch spriteBatch, Point costDrawPositionTopLeft) + { + if (CurrentlyHeldItem.IsAir) + 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 == EnchantmentManager.UpgradeEnchantName) + cost = (int)MathHelper.Min(cost, Item.buyPrice(5)) * 5; + + // Draw the coin costs. + string costText = "Cost: "; + Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, costText, costDrawPositionTopLeft.X, costDrawPositionTopLeft.Y + 45f * Main.UIScale, Color.White * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, Main.UIScale); + costDrawPositionTopLeft.X += (int)((Main.fontMouseText.MeasureString(costText).X * 0.5f + 12f) * Main.UIScale); + + int[] coinsArray = Utils.CoinsSplit(cost); + for (int i = 0; i < 4; i++) + { + Vector2 drawPosition = new Vector2(costDrawPositionTopLeft.X + (ChatManager.GetStringSize(Main.fontMouseText, costText, Vector2.One, -1f).X + ((24 * i) - 24f)) * Main.UIScale, costDrawPositionTopLeft.Y + 54f * Main.UIScale); + spriteBatch.Draw(Main.itemTexture[ItemID.PlatinumCoin - i], drawPosition, null, Color.White, 0f, Main.itemTexture[ItemID.PlatinumCoin - i].Size() * 0.5f, Main.UIScale, SpriteEffects.None, 0f); + Utils.DrawBorderStringFourWay(spriteBatch, Main.fontItemStack, coinsArray[3 - i].ToString(), drawPosition.X - 11f, drawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f * Main.UIScale); + } + + return cost; + } + + public static void DrawEnchantmentDescription(SpriteBatch spriteBatch, Point descriptionDrawPositionTopLeft) + { + Vector2 vectorDrawPosition = descriptionDrawPositionTopLeft.ToVector2(); + Vector2 scale = new Vector2(0.67f, 0.7f) * MathHelper.Clamp(ResolutionRatio, 0.825f, 1f) * Main.UIScale; + foreach (string line in Utils.WordwrapString(SelectedEnchantment.Value.Description, Main.fontMouseText, 465, 10, out _)) + { + if (string.IsNullOrEmpty(line)) + continue; + + ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, line, vectorDrawPosition, Color.Orange, 0f, Vector2.Zero, scale); + vectorDrawPosition.Y += Main.UIScale * 16f; + } + } + + public static void DrawIcon(SpriteBatch spriteBatch, Vector2 drawPositionTopLeft, Texture2D texture) + { + spriteBatch.Draw(texture, drawPositionTopLeft, null, Color.White, 0f, Vector2.Zero, Main.UIScale, SpriteEffects.None, 0f); + } + + public static void DrawItemIcon(SpriteBatch spriteBatch, Vector2 itemSlotDrawPosition, Vector2 reforgeIconDrawPosition, Vector2 scale, out bool isHoveringOverItemIcon, out bool isHoveringOverReforgeIcon) + { + isHoveringOverReforgeIcon = false; + Texture2D itemSlotTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseItemSlot"); + + Texture2D reforgeIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_Button"); + Rectangle reforgeIconArea = new Rectangle((int)reforgeIconDrawPosition.X, (int)reforgeIconDrawPosition.Y, (int)(reforgeIconTexture.Width * scale.X), (int)(reforgeIconTexture.Height * scale.Y)); + + // Have the reforge icon light up if the mouse is hovering over it. + if (MouseScreenArea.Intersects(reforgeIconArea)) + { + reforgeIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ButtonHovered"); + isHoveringOverReforgeIcon = true; + } + + if (ReforgeButtonClickCountdown > 0f) + reforgeIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ButtonClicked"); + + // This will be used for item deposit/withdrawal logic. + isHoveringOverItemIcon = MouseScreenArea.Intersects(new Rectangle((int)itemSlotDrawPosition.X, (int)itemSlotDrawPosition.Y, (int)(itemSlotTexture.Width * scale.X), (int)(itemSlotTexture.Height * scale.Y))); + + spriteBatch.Draw(itemSlotTexture, itemSlotDrawPosition, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + + // Draw the draw the item within the slot, if it exists. + if (!CurrentlyHeldItem.IsAir) + AttemptToDrawItemInIcon(spriteBatch, itemSlotDrawPosition); + + spriteBatch.Draw(reforgeIconTexture, reforgeIconDrawPosition, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + } + + public static void AttemptToDrawItemInIcon(SpriteBatch spriteBatch, Vector2 drawPosition) + { + float inventoryScale = Main.inventoryScale; + Texture2D itemTexture = Main.itemTexture[CurrentlyHeldItem.type]; + Rectangle itemFrame = itemTexture.Frame(1, 1, 0, 0); + bool hasMultipleFrames = Main.itemAnimations[CurrentlyHeldItem.type] != null; + if (hasMultipleFrames) + itemFrame = Main.itemAnimations[CurrentlyHeldItem.type].GetFrame(itemTexture); + + float baseScale = Main.UIScale; + Color _ = Color.White; + ItemSlot.GetItemLight(ref _, ref baseScale, CurrentlyHeldItem, false); + + float itemScale = 1f; + + // Ensure that the item being drawn does not exceed a certain size. + // If it does, constrict its scale to prevent it from going beyond the maximum. + if (itemFrame.Width > 36 || itemFrame.Height > 36) + itemScale = 36f / MathHelper.Max(itemFrame.Width, itemFrame.Height); + + itemScale *= inventoryScale * baseScale; + drawPosition += Vector2.One * 23f * baseScale; + + // Draw the item. + if (hasMultipleFrames || ItemLoader.PreDrawInInventory(CurrentlyHeldItem, spriteBatch, drawPosition, itemFrame, CurrentlyHeldItem.GetAlpha(Color.White), CurrentlyHeldItem.GetColor(Color.White), itemTexture.Size() * 0.5f, itemScale)) + { + spriteBatch.Draw(itemTexture, drawPosition, itemFrame, CurrentlyHeldItem.GetAlpha(Color.White), 0f, itemFrame.Size() * 0.5f, itemScale, SpriteEffects.None, 0f); + spriteBatch.Draw(itemTexture, drawPosition, itemFrame, CurrentlyHeldItem.GetColor(Color.White), 0f, itemFrame.Size() * 0.5f, itemScale, SpriteEffects.None, 0f); + } + } + + public static void InteractWithItemSlot() + { + if (!CurrentlyHeldItem.IsAir) + { + // Display item stats. + Main.HoverItem = CurrentlyHeldItem.Clone(); + + // Force the HoverItem to be displayed. + Main.instance.MouseTextHackZoom(string.Empty); + } + + // Attempt to exchange if the slot is clicked. + if (Main.mouseLeftRelease && Main.mouseLeft && (Main.mouseItem.CanBeEnchantedBySomething() || Main.mouseItem.IsAir)) + { + EnchantIndex = 0; + Utils.Swap(ref Main.mouseItem, ref CurrentlyHeldItem); + Main.PlaySound(SoundID.Grab); + } + } + + public static void DrawAndInteractWithButtons(SpriteBatch spriteBatch, IEnumerable possibleEnchantments, Vector2 topButtonTopLeft, Vector2 bottomButtonTopLeft, Vector2 scale) + { + // Leave the arrows blank if no possible enchants exist. + if (possibleEnchantments.Count() == 0) + return; + + // Decide textures. + Texture2D topArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUp"); + Texture2D bottomArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDown"); + if (TopButtonClickCountdown > 0f) + topArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUpClicked"); + if (BottomButtonClickCountdown > 0f) + bottomArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDownClicked"); + + Rectangle topButtonArea = new Rectangle((int)topButtonTopLeft.X, (int)topButtonTopLeft.Y, (int)(topArrowTexture.Width * scale.X), (int)(topArrowTexture.Height * scale.Y)); + Rectangle bottomButtonArea = new Rectangle((int)bottomButtonTopLeft.X, (int)bottomButtonTopLeft.Y, (int)(bottomArrowTexture.Width * scale.X), (int)(bottomArrowTexture.Height * scale.Y)); + bool hoveringOverTopArrow = MouseScreenArea.Intersects(topButtonArea); + bool hoveringOverBottomArrow = MouseScreenArea.Intersects(bottomButtonArea); + if (hoveringOverTopArrow) + topArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowUpHovered"); + + if (hoveringOverBottomArrow) + bottomArrowTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CalamitasCurseUI_ArrowDownHovered"); + + // Draw the arrows. + if (EnchantIndex > 0) + spriteBatch.Draw(topArrowTexture, topButtonTopLeft, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + if (EnchantIndex < possibleEnchantments.Count() - 1) + spriteBatch.Draw(bottomArrowTexture, bottomButtonTopLeft, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + + if (Main.mouseLeft && Main.mouseLeftRelease) + { + // Decement the enchantment index if the top button is pressed. + if (hoveringOverTopArrow && EnchantIndex > 0) + { + EnchantIndex--; + TopButtonClickCountdown = 15f; + Main.PlaySound(SoundID.MenuTick); + } + + // Increment the enchantment index if the bottom button is pressed. + if (hoveringOverBottomArrow && EnchantIndex < possibleEnchantments.Count() - 1) + { + EnchantIndex++; + BottomButtonClickCountdown = 15f; + Main.PlaySound(SoundID.MenuTick); + } + } + } + + public static void DrawEnchantmentName(SpriteBatch spriteBatch, Vector2 nameDrawCenter) + { + Vector2 scale = new Vector2(0.8f, 0.745f) * Main.UIScale; + float textWidth = Main.fontMouseText.MeasureString(SelectedEnchantment.Value.Name).X * scale.X; + Color drawColor = SelectedEnchantment.Value.Equals(EnchantmentManager.ClearEnchantment) ? Color.White : Color.Orange; + nameDrawCenter.X -= textWidth * 0.5f; + ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontMouseText, SelectedEnchantment.Value.Name, nameDrawCenter, drawColor, 0f, Vector2.Zero, scale); + } + + public static void InteractWithEnchantIcon(int cost) + { + // If there's no valid item in the slot, do nothing. + if (CurrentlyHeldItem.IsAir) + 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); + + if (SelectedEnchantment.Value.Name == EnchantmentManager.UpgradeEnchantName) + { + 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, + // such as absurd damage boosts. + if (Main.cpItem is null) + Main.cpItem = new Item(); + Main.cpItem.SetDefaults(Main.cpItem.type); + + if (SelectedEnchantment.Value.Name != EnchantmentManager.UpgradeEnchantName) + { + Main.cpItem.Calamity().AppliedEnchantment = SelectedEnchantment.Value; + SelectedEnchantment.Value.CreationEffect?.Invoke(Main.cpItem); + } + + // Take away the money for the cost. + Main.LocalPlayer.BuyItem(cost); + + // Reset the enchantment index to prevent index problems on a different item. + EnchantIndex = 0; + + Main.PlaySound(SoundID.DD2_BetsyFlameBreath, Main.LocalPlayer.Center); + + if (SelectedEnchantment.Value.Name == EnchantmentManager.UpgradeEnchantName) + Main.PlaySound(SoundID.DD2_DarkMageHealImpact, Main.LocalPlayer.Center); + } + } +} diff --git a/UI/CalamitasEnchantments/Enchantment.cs b/UI/CalamitasEnchantments/Enchantment.cs new file mode 100644 index 0000000000..e24f411e0e --- /dev/null +++ b/UI/CalamitasEnchantments/Enchantment.cs @@ -0,0 +1,64 @@ +using System; +using Terraria; + +namespace CalamityMod.UI.CalamitasEnchants +{ + public struct Enchantment + { + public string Name; + public string Description; + public string IconTexturePath; + public Action CreationEffect; + public Action HoldEffect; + + public int ID { get; internal set; } + + // This is internal because CanBeAppliedTo should be used over this field directly. + // Using that has the benefit of null checks and is objectively superior to using the raw delegate. + internal Predicate ApplyRequirement; + public Enchantment(string name, string description, int id, string iconTexturePath, Action creationEffect, Action holdEffect, Predicate requirement) + { + Name = name; + Description = description; + CreationEffect = creationEffect; + HoldEffect = holdEffect; + ApplyRequirement = requirement; + ID = id; + IconTexturePath = iconTexturePath; + } + public Enchantment(string name, string description, int id, string iconTexturePath, Action holdEffect, Predicate requirement) + { + Name = name; + Description = description; + CreationEffect = null; + HoldEffect = holdEffect; + ApplyRequirement = requirement; + ID = id; + IconTexturePath = iconTexturePath; + } + public Enchantment(string name, string description, int id, string iconTexturePath, Action creationEffect, Predicate requirement) + { + Name = name; + Description = description; + CreationEffect = creationEffect; + HoldEffect = null; + ApplyRequirement = requirement; + ID = id; + IconTexturePath = iconTexturePath; + } + + public bool CanBeAppliedTo(Item item) + { + // "Empty" items can never be enchanted. + if (item is null || item.IsAir) + return false; + + // If there is no requirement, always return true, bar the above requirement. + if (ApplyRequirement is null) + return true; + + // Otherwise return what the defined requirement says is needed. + return ApplyRequirement(item); + } + } +} diff --git a/UI/CalamitasEnchantments/EnchantmentManager.cs b/UI/CalamitasEnchantments/EnchantmentManager.cs new file mode 100644 index 0000000000..e30094da53 --- /dev/null +++ b/UI/CalamitasEnchantments/EnchantmentManager.cs @@ -0,0 +1,316 @@ +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.NPCs.Other; +using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.UI.CalamitasEnchants +{ + public static class EnchantmentManager + { + internal const int ClearEnchantmentID = -18591774; + internal const string UpgradeEnchantName = "Exhume"; + 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) + { + // Do nothing if the item cannot be enchanted. + 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) + { + yield return ClearEnchantment; + yield break; + } + + // Check based on all the requirements for all enchantments. + foreach (Enchantment enchantment in EnchantmentList) + { + // Don't incorporate an enchantment in the list if the item already has it. + if (item.Calamity().AppliedEnchantment.HasValue && item.Calamity().AppliedEnchantment.Value.Equals(enchantment)) + continue; + + if (enchantment.ApplyRequirement(item)) + yield return enchantment; + } + } + + public static Enchantment? FindByID(int id) + { + Enchantment? enchantment = EnchantmentList.FirstOrDefault(enchant => enchant.ID == id); + if (enchantment.HasValue && !enchantment.Value.Equals(default(Enchantment))) + return enchantment; + return null; + } + + public static void ConstructFromModcall(IEnumerable parameters) + { + int secondaryArgumentCount = parameters.Count(); + if (secondaryArgumentCount < 5) + throw new ArgumentNullException("ERROR: A minimum of 4 arguments must be supplied to this command; a name, a description, an id, and a requirement predicate."); + if (secondaryArgumentCount > 7) + throw new ArgumentNullException("ERROR: A maximum of 6 arguments can be supplied to this command."); + + string name = string.Empty; + string description = string.Empty; + int id = -1; + string iconTexturePath = null; + Predicate requirement = null; + Action creationEffect = null; + Action holdEffect = null; + + // First element - the name. + if (parameters.ElementAt(0) is string nameElement) + name = nameElement; + else + throw new ArgumentException("The first argument to this command must be a string."); + + // Second element - the description. + if (parameters.ElementAt(1) is string descriptionElement) + description = descriptionElement; + else + throw new ArgumentException("The second argument to this command must be a string."); + + // Third element - the ID. + if (parameters.ElementAt(2) is int idElement) + id = idElement; + else + throw new ArgumentException("The third argument to this command must be an int."); + + // Fourth element - the requirement predicate. This determines if an item can be enchanted by said enchant or not. + if (parameters.ElementAt(3) is Predicate requirementElement) + requirement = requirementElement; + else + throw new ArgumentException("The fourth argument to this command must be an Item Predicate."); + + // Fifth element - the texture path. This determines what icon is drawn on the UI when selected. It may be null to specify that none should be drawn. + if (parameters.ElementAt(4) is string iconTexturePathElement) + iconTexturePath = iconTexturePathElement; + else + throw new ArgumentException("The fifth argument to this command must be a string."); + + // Optional elements - creation and hold effects. + switch (secondaryArgumentCount) + { + case 6: + object sixthElement = parameters.ElementAt(4); + if (sixthElement is Action creationElement) + creationEffect = creationElement; + else if (sixthElement is Action holdElement) + holdEffect = holdElement; + else + throw new ArgumentException("The sixth argument to this command must be an Item or Player Action."); + break; + case 7: + sixthElement = parameters.ElementAt(4); + object seventhElement = parameters.ElementAt(5); + if (sixthElement is Action creationElement2) + { + creationEffect = creationElement2; + holdEffect = seventhElement as Action; + } + else if (sixthElement is Action holdElement2) + { + creationEffect = seventhElement as Action; + holdEffect = holdElement2; + } + else + throw new ArgumentException("The sixth argument to this command must be an Item or Player Action and the sixth must be the other action type."); + break; + } + + // Ensure the enchantment's ID is not already claimed. + if (EnchantmentList.Any(enchant => enchant.ID == id) || id == ClearEnchantmentID) + throw new ArgumentException("An enchantment with this ID already exists. Another one must be specified."); + + EnchantmentList.Add(new Enchantment(name, description, id, iconTexturePathElement, creationEffect, holdEffect, requirement)); + } + + internal static void LoadAllEnchantments() + { + EnchantmentList = new List + { + new Enchantment(UpgradeEnchantName, "Transforms this item into something significantly stronger.", + 1, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Exhumed", + null, + null, + item => ItemUpgradeRelationship.ContainsKey(item.type)), + + new Enchantment("Indignant", "Summons demons that harm you but drop healing items on death on item usage.", + 100, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Indignant", + null, + player => player.Calamity().cursedSummonsEnchant = true, + item => item.damage > 0 && item.maxStack == 1 && item.summon), + + new Enchantment("Aflame", "Lights enemies ablaze on hit but also causes the user to take damage over time when holding this item.", + 200, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Aflame", + null, + player => player.Calamity().flamingItemEnchant = true, + item => item.damage > 0 && item.maxStack == 1 && !item.summon), + + new Enchantment("Oblatory", "Reduces mana cost and greatly increases damage but sometimes causes this item to use your life.", + 300, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Oblatory", + item => + { + item.damage = (int)(item.damage * 1.5); + item.mana = (int)Math.Ceiling(item.mana * 0.6); + }, + player => player.Calamity().lifeManaEnchant = true, + item => item.damage > 0 && item.maxStack == 1 && item.magic && item.mana > 0), + + new Enchantment("Resentful", "Makes the damage of projectiles vary based on how far the hit target is from you. The farther, the more damage, and vice versa.", + 400, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Resentful", + null, + player => player.Calamity().farProximityRewardEnchant = true, + item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None), + + new Enchantment("Bloodthirsty", "Makes the damage of projectiles vary based on how far the hit target is from you. The closer, the more damage, and vice versa.", + 500, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Bloodthirsty", + null, + player => player.Calamity().closeProximityRewardEnchant = true, + item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None), + + new Enchantment("Ephemeral", "Causes the damage output of this item to discharge from exhaustive use. Its damage returns naturally when not being used.", + 600, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Ephemeral", + null, + player => player.Calamity().dischargingItemEnchant = true, + item => item.damage > 0 && item.maxStack == 1 && !item.summon), + + new Enchantment("Hellbound", "Causes minions to be created with a 40 second timer. Once it runs out, they explode violently. Minions do more damage the longer they live and idly explode as well.", + 700, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Hellbound", + null, + player => player.Calamity().explosiveMinionsEnchant = true, + item => item.damage > 0 && item.maxStack == 1 && item.summon), + + new Enchantment("Tainted", "Removes projectile shooting capabilities of this item. In exchange, two skeletal arms are released on use that slice at the mouse position.", + 800, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Tainted", + item => item.useTime = item.useAnimation = 25, + player => + { + if (Main.gameMenu) + return; + + player.Calamity().bladeArmEnchant = true; + bool armsArePresent = false; + int armType = ModContent.ProjectileType(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != armType || Main.projectile[i].owner != player.whoAmI || !Main.projectile[i].active) + continue; + + armsArePresent = true; + break; + } + + if (Main.myPlayer == player.whoAmI && !armsArePresent) + { + // 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, 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, 1f, player.ActiveItem().type); + if (Main.projectile.IndexInRange(blade)) + Main.projectile[blade].localAI[0] = -80f; + } + }, + item => item.damage > 0 && item.maxStack == 1 && item.melee && !item.noUseGraphic && item.shoot > ProjectileID.None), + + new Enchantment("Traitorous", "Causes this item to sometimes release a monster that hurts both you and enemies when you have less than 50% mana.", + 900, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Traitorous", + null, + player => player.Calamity().manaMonsterEnchant = true, + item => item.damage > 0 && item.maxStack == 1 && item.magic && item.mana > 0), + + new Enchantment("Withering", "You heal when hurt based on damage dealt. After being hurt, the weapon rapidly drains your life to deal massive damage.", + 1000, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Withered", + null, + player => player.Calamity().witheringWeaponEnchant = true, + item => item.damage > 0 && item.maxStack == 1 && !item.summon), + + new Enchantment("Persecuted", "When attacked, or over time, demon portals appear near you. If sufficiently damaged they are friendly; otherwise they attack you.", + 1100, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Persecuted", + null, + player => player.Calamity().persecutedEnchant = true, + item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None), + + new Enchantment("Lecherous", "Spawns a resiliant brimstone orb that stays between you and your mouse that interferes with your homing weapons. It releases a bunch of hearts on death.", + 1200, + "CalamityMod/ExtraTextures/UI/EnchantmentSymbols/CurseIcon_Lecherous", + null, + player => + { + if (Main.gameMenu) + return; + + player.Calamity().lecherousOrbEnchant = true; + + bool orbIsPresent = false; + int orbType = ModContent.NPCType(); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].type != orbType || Main.npc[i].target != player.whoAmI || !Main.npc[i].active) + continue; + + orbIsPresent = true; + break; + } + + if (Main.myPlayer == player.whoAmI && !orbIsPresent) + { + int orb = NPC.NewNPC((int)player.Center.X, (int)player.Center.Y - 5, orbType); + if (Main.npc.IndexInRange(orb)) + Main.npc[orb].TargetClosest(); + } + }, + item => item.damage > 0 && item.maxStack == 1 && item.shoot > ProjectileID.None), + }; + + // Special disenchantment thing. This is separated from the list on purpose. + ClearEnchantment = new Enchantment("Disenchant", + string.Empty, + ClearEnchantmentID, + null, + item => item.Calamity().AppliedEnchantment = null, + item => item.maxStack == 1 && item.shoot >= ProjectileID.None); + + ItemUpgradeRelationship = new Dictionary() + { + [ModContent.ItemType()] = ModContent.ItemType(), + [ModContent.ItemType()] = ModContent.ItemType(), + }; + } + + internal static void UnloadAllEnchantments() + { + EnchantmentList = null; + ItemUpgradeRelationship = null; + } + } +} diff --git a/UI/ModeIndicatorUI.cs b/UI/ModeIndicatorUI.cs index 93e9f8b1e2..5967268016 100644 --- a/UI/ModeIndicatorUI.cs +++ b/UI/ModeIndicatorUI.cs @@ -9,9 +9,9 @@ namespace CalamityMod.UI public class ModeIndicatorUI { public static readonly Vector2 OffsetToAreaCenter = new Vector2(0f, 4f); - public static Vector2 DifficultyIconOffset => new Vector2(0f, -16f); - public static Vector2 ArmageddonIconOffset => new Vector2(11.5f, 7f); - public static Vector2 DefiledRuneIconOffset => new Vector2(-12f, 7); + public static Vector2 DifficultyIconOffset => new Vector2(0f, -13f); + public static Vector2 ArmageddonIconOffset => new Vector2(12f, 7f); + public static Vector2 MaliceIconOffset => new Vector2(-12f, 7f); public static void Draw(SpriteBatch spriteBatch) { // The mode indicator should only be displayed when the inventory is open, to prevent obstruction. @@ -22,25 +22,51 @@ namespace CalamityMod.UI Texture2D revengeanceIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicatorRev"); Texture2D deathIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicatorDeath"); Texture2D armageddonIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicatorArma"); + Texture2D maliceIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicatorMalice"); - // TODO -- When Malice is added, replace this with Malice's indicator. - Texture2D defiledRuneIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicatorRune"); + Rectangle mouseRectangle = Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); Vector2 drawCenter = new Vector2(Main.screenWidth - 400f, 72f) + outerAreaTexture.Size() * 0.5f; spriteBatch.Draw(outerAreaTexture, drawCenter, null, Color.White, 0f, outerAreaTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); + Texture2D difficultyIconToUse = CalamityWorld.death ? deathIconTexture : revengeanceIconTexture; + bool modeIsActive = CalamityWorld.revenge; + bool renderingText = false; if (CalamityWorld.revenge) + spriteBatch.Draw(difficultyIconToUse, drawCenter + DifficultyIconOffset, null, Color.White, 0f, difficultyIconToUse.Size() * 0.5f, 1f, SpriteEffects.None, 0f); + + // Rev/Death active text. + if (mouseRectangle.Intersects(Utils.CenteredRectangle(drawCenter + DifficultyIconOffset, difficultyIconToUse.Size()))) { - Texture2D difficultyIconToUse = CalamityWorld.death ? deathIconTexture : revengeanceIconTexture; - spriteBatch.Draw(difficultyIconToUse, drawCenter + DifficultyIconOffset, null, Color.White, 0f, revengeanceIconTexture.Size() * 0.5f, 0.9f, SpriteEffects.None, 0f); + Main.instance.MouseText($"{(CalamityWorld.death ? "Death" : "Revengeance")} Mode is {(modeIsActive ? "active" : "not active")}."); + renderingText = true; } if (CalamityWorld.armageddon) - spriteBatch.Draw(armageddonIconTexture, drawCenter + ArmageddonIconOffset, null, Color.White, 0f, revengeanceIconTexture.Size() * 0.5f, 0.9f, SpriteEffects.None, 0f); + { + spriteBatch.Draw(armageddonIconTexture, drawCenter + ArmageddonIconOffset, null, Color.White, 0f, armageddonIconTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); + } - /*if (false) - spriteBatch.Draw(defiledRuneIconTexture, drawCenter + DefiledRuneIconOffset, null, Color.White, 0f, revengeanceIconTexture.Size() * 0.5f, 0.9f, SpriteEffects.None, 0f);*/ + // Armageddon active text. + if (!renderingText && mouseRectangle.Intersects(Utils.CenteredRectangle(drawCenter + ArmageddonIconOffset, armageddonIconTexture.Size()))) + { + Main.instance.MouseText($"Armageddon is {(CalamityWorld.armageddon ? "active" : "not active")}."); + renderingText = true; + } + + if (CalamityWorld.malice) + spriteBatch.Draw(maliceIconTexture, drawCenter + MaliceIconOffset, null, Color.White, 0f, maliceIconTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); + + // Malice active text. + if (!renderingText && mouseRectangle.Intersects(Utils.CenteredRectangle(drawCenter + MaliceIconOffset, armageddonIconTexture.Size()))) + { + Main.instance.MouseText($"Malice Mode is {(CalamityWorld.malice ? "active" : "not active")}."); + renderingText = true; + } + + if (renderingText) + Main.instance.MouseTextHackZoom(string.Empty); } } } diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index 697e5f7931..a3eefd6d7e 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -112,6 +112,17 @@ namespace CalamityMod } } + /// + /// Sets a 's arbitrarily. + /// + /// The sprite batch. + /// The blend state to use. + public static void SetBlendState(this SpriteBatch spriteBatch, BlendState blendState) + { + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, blendState, Main.DefaultSamplerState, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Main.GameViewMatrix.TransformationMatrix); + } + // Used for bullets. This lets you draw afterimages while keeping the hitbox at the front of the projectile. // This supports type 0 and type 2 afterimages. Vanilla bullets never have type 2 afterimages. public static void DrawAfterimagesFromEdge(Projectile proj, int mode, Color lightColor, Texture2D texture = null) diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index d743b3f451..00b12acb8e 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -1,6 +1,8 @@ +using CalamityMod.UI.CalamitasEnchants; using CalamityMod.World; using Microsoft.Xna.Framework; using System.Collections.Generic; +using System.Linq; using System.Text; using Terraria; using Terraria.ID; @@ -196,6 +198,25 @@ namespace CalamityMod return moved; } + /// + /// Determines if a given item is enchanted based on Calamitas' special system. + /// + /// The item to check. + public static bool IsEnchanted(this Item item) + { + // If the item is air just immediately return false. + // It will not have a CalamityGlobalItem instance to use and attempting to do anything with it + // would just result in errors. + if (item.IsAir) + return false; + + // If the item is contained in the enchant upgrade result relationship, return true. + if (EnchantmentManager.ItemUpgradeRelationship.ContainsValue(item.type)) + return true; + + return item.Calamity().AppliedEnchantment.HasValue; + } + public static Rectangle FixSwingHitbox(float hitboxWidth, float hitboxHeight) { Player player = Main.player[Main.myPlayer]; @@ -363,6 +384,12 @@ namespace CalamityMod } #endregion + /// + /// Determines if an item can be enchanted by any item at all via Calamitas' enchantment system. + /// + /// The item to check. + public static bool CanBeEnchantedBySomething(this Item item) => EnchantmentManager.EnchantmentList.Any(enchantment => enchantment.ApplyRequirement(item)); + public static void ConsumeItemViaQuickBuff(Player player, Item item, int buffType, int buffTime, bool reducedPotionSickness) { bool showsOver = false;