From 6999f014a77cfa95b094cf1e468931a6bcbbbb2a Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 13 May 2020 17:18:51 -0400 Subject: [PATCH] added deflection scarf --- Buffs/Cooldowns/DeflectionScarfCooldown.cs | 24 ++++++++++ Buffs/StatBuffs/DeflectionScarfBoost.cs | 23 ++++++++++ Buffs/StatBuffs/ScarfMeleeBoost.cs | 2 +- CalPlayer/CalamityPlayer.cs | 42 +++++++++++++---- CalPlayer/CalamityPlayerMiscEffects.cs | 5 ++ Items/Accessories/CounterScarf.cs | 2 + Items/Accessories/DeflectionScarf.cs | 53 ++++++++++++++++++++++ Items/CalamityGlobalItem.cs | 4 +- 8 files changed, 145 insertions(+), 10 deletions(-) create mode 100644 Buffs/Cooldowns/DeflectionScarfCooldown.cs create mode 100644 Buffs/StatBuffs/DeflectionScarfBoost.cs create mode 100644 Items/Accessories/DeflectionScarf.cs diff --git a/Buffs/Cooldowns/DeflectionScarfCooldown.cs b/Buffs/Cooldowns/DeflectionScarfCooldown.cs new file mode 100644 index 0000000000..eee260188e --- /dev/null +++ b/Buffs/Cooldowns/DeflectionScarfCooldown.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Cooldowns +{ + public class DeflectionScarfCooldown : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Deflection Scarf Cooldown"); + Description.SetDefault("Your dodge is recharging"); + 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().dScarfCooldown = true; + } + } +} diff --git a/Buffs/StatBuffs/DeflectionScarfBoost.cs b/Buffs/StatBuffs/DeflectionScarfBoost.cs new file mode 100644 index 0000000000..b6e568014a --- /dev/null +++ b/Buffs/StatBuffs/DeflectionScarfBoost.cs @@ -0,0 +1,23 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.StatBuffs +{ + public class DeflectionScarfBoost : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Deflection Scarf Boost"); + Description.SetDefault("10% increased damage, 10% increased crit chance, and 15% increased melee speed"); + Main.debuff[Type] = false; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + longerExpertDebuff = false; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().dScarfBoost = true; + } + } +} diff --git a/Buffs/StatBuffs/ScarfMeleeBoost.cs b/Buffs/StatBuffs/ScarfMeleeBoost.cs index 940411c84d..4733a30f6b 100644 --- a/Buffs/StatBuffs/ScarfMeleeBoost.cs +++ b/Buffs/StatBuffs/ScarfMeleeBoost.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Buffs.StatBuffs public override void SetDefaults() { DisplayName.SetDefault("Scarf Boost"); - Description.SetDefault("10% increased damage, 5% increased crit chance, and 10% increased melee speed"); + Description.SetDefault("10% increased damage, 5% increased crit chance, and 5% increased melee speed"); Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index e006f27d99..a350a75f46 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -367,9 +367,11 @@ namespace CalamityMod.CalPlayer public bool vexation = false; public bool fBulwark = false; public bool dodgeScarf = false; + public bool deflectionScarf = false; public bool badgeOfBravery = false; public bool badgeOfBraveryRare = false; public bool scarfCooldown = false; + public bool dScarfCooldown = false; public bool cryogenSoul = false; public bool yInsignia = false; public bool eGauntlet = false; @@ -686,6 +688,7 @@ namespace CalamityMod.CalPlayer public bool graxDefense = false; public bool encased = false; public bool sMeleeBoost = false; + public bool dScarfBoost = false; public bool tFury = false; public bool cadence = false; public bool omniscience = false; @@ -1306,7 +1309,9 @@ namespace CalamityMod.CalPlayer fasterRogueLevel = false; dodgeScarf = false; + deflectionScarf = false; scarfCooldown = false; + dScarfCooldown = false; elysianAegis = false; @@ -1647,6 +1652,7 @@ namespace CalamityMod.CalPlayer graxDefense = false; encased = false; sMeleeBoost = false; + dScarfBoost = false; tFury = false; cadence = false; omniscience = false; @@ -1910,6 +1916,7 @@ namespace CalamityMod.CalPlayer clamity = false; snowmanNoseless = false; scarfCooldown = false; + dScarfCooldown = false; godSlayerCooldown = false; abyssalDivingSuitCooldown = false; abyssalDivingSuitPlateHits = 0; @@ -1975,6 +1982,7 @@ namespace CalamityMod.CalPlayer graxDefense = false; encased = false; sMeleeBoost = false; + dScarfBoost = false; tFury = false; cadence = false; omniscience = false; @@ -2446,7 +2454,9 @@ namespace CalamityMod.CalPlayer player.Teleport(teleportLocation, 4, 0); NetMessage.SendData(65, -1, -1, null, 0, (float)player.whoAmI, teleportLocation.X, teleportLocation.Y, 1, 0, 0); - if (scarfCooldown) + if (dScarfCooldown) + player.AddBuff(BuffID.ChaosState, (int)(chaosStateDuration * 1.5), true); + else if (scarfCooldown) player.AddBuff(BuffID.ChaosState, chaosStateDuration * 2, true); else player.AddBuff(BuffID.ChaosState, chaosStateDuration, true); @@ -2497,7 +2507,9 @@ namespace CalamityMod.CalPlayer player.Teleport(teleportLocation, 1, 0); NetMessage.SendData(65, -1, -1, null, 0, (float)player.whoAmI, teleportLocation.X, teleportLocation.Y, 1, 0, 0); - if (scarfCooldown) + if (dScarfCooldown) + player.AddBuff(BuffID.ChaosState, (int)(chaosStateDuration * 1.5), true); + else if (scarfCooldown) player.AddBuff(BuffID.ChaosState, chaosStateDuration * 2, true); else player.AddBuff(BuffID.ChaosState, chaosStateDuration, true); @@ -3182,6 +3194,10 @@ namespace CalamityMod.CalPlayer { meleeSpeedMult += 0.05f; } + if (dScarfBoost) + { + meleeSpeedMult += 0.15f; + } if (yPower) { meleeSpeedMult += 0.05f; @@ -4769,6 +4785,7 @@ namespace CalamityMod.CalPlayer if (item.melee) { double damageAdd = (dodgeScarf ? 0.2 : 0) + + (deflectionScarf ? 0.1 : 0) + ((aBulwarkRare && aBulwarkRareMeleeBoostTimer > 0) ? 2 : 0) + (DoGLore ? 0.5 : 0) + (fungalSymbiote ? 0.25 : 0); @@ -5019,6 +5036,7 @@ namespace CalamityMod.CalPlayer if (isTrueMelee) { double damageAdd = (dodgeScarf ? 0.2 : 0) + + (deflectionScarf ? 0.1 : 0) + ((aBulwarkRare && aBulwarkRareMeleeBoostTimer > 0) ? 2 : 0) + (DoGLore ? 0.5 : 0) + (fungalSymbiote ? 0.25 : 0); @@ -7496,9 +7514,9 @@ namespace CalamityMod.CalPlayer else if (dashMod > 0 && !player.mount.Active) { float dashDistance; - if (dashMod == 1) //Counter Scarf + if (dashMod == 1) //Counter and Deflection Scarf { - dashDistance = 14.5f; + dashDistance = deflectionScarf ? 16.9f : 14.5f; int direction = 0; bool justDashed = false; if (dashTimeMod > 0) @@ -7537,7 +7555,7 @@ namespace CalamityMod.CalPlayer } if (justDashed) { - player.velocity.X = dashDistance * (float)direction; //eoc dash amount + player.velocity.X = dashDistance * (float)direction; //eoc dash amount (deflection = asgard's) Point point = (player.Center + new Vector2((float)(direction * player.width / 2 + 2), player.gravDir * (float)-(float)player.height / 2f + player.gravDir * 2f)).ToTileCoordinates(); Point point2 = (player.Center + new Vector2((float)(direction * player.width / 2 + 2), 0f)).ToTileCoordinates(); if (WorldGen.SolidOrSlopedTile(point.X, point.Y) || WorldGen.SolidOrSlopedTile(point2.X, point2.Y)) @@ -7940,10 +7958,18 @@ namespace CalamityMod.CalPlayer private void OnDodge() { - if (player.whoAmI == Main.myPlayer && dodgeScarf && !scarfCooldown) + if (player.whoAmI == Main.myPlayer && dodgeScarf && !scarfCooldown && !dScarfCooldown) { - player.AddBuff(ModContent.BuffType(), 540); - player.AddBuff(ModContent.BuffType(), player.chaosState ? 1800 : 900); + if (deflectionScarf) + { + player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(6f)); + player.AddBuff(ModContent.BuffType(), player.chaosState ? CalamityUtils.SecondsToFrames(20f) : CalamityUtils.SecondsToFrames(13f)); + } + else + { + player.AddBuff(ModContent.BuffType(), 540); + player.AddBuff(ModContent.BuffType(), player.chaosState ? 1800 : 900); + } player.immune = true; player.immuneTime = player.longInvince ? 100 : 60; for (int k = 0; k < player.hurtCooldowns.Length; k++) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index cce27f6054..2ba91b9d9c 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -2342,6 +2342,11 @@ namespace CalamityMod.CalPlayer player.meleeDamage += 0.2f; } + if (modPlayer.dScarfBoost) + { + player.allDamage += 0.1f; + modPlayer.AllCritBoost(10); + } if (modPlayer.sMeleeBoost) { player.allDamage += 0.1f; diff --git a/Items/Accessories/CounterScarf.cs b/Items/Accessories/CounterScarf.cs index d948773066..569a249447 100644 --- a/Items/Accessories/CounterScarf.cs +++ b/Items/Accessories/CounterScarf.cs @@ -26,6 +26,8 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } + public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().dodgeScarf; + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/DeflectionScarf.cs b/Items/Accessories/DeflectionScarf.cs new file mode 100644 index 0000000000..cd02dbed48 --- /dev/null +++ b/Items/Accessories/DeflectionScarf.cs @@ -0,0 +1,53 @@ +using CalamityMod.CalPlayer; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + [AutoloadEquip(EquipType.Neck)] + public class DeflectionScarf : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Deflection Scarf"); + Tooltip.SetDefault("True melee strikes deal 30% more damage\n" + + "Grants the ability to dash; dashing into an attack will cause you to dodge it\n" + + "After a dodge you will be granted a buff to all damage, melee speed, and all crit chance for a short time\n" + + "After a successful dodge you must wait 13 seconds before you can dodge again"); + } + + public override void SetDefaults() + { + item.width = 26; + item.height = 26; + item.accessory = true; + item.value = CalamityGlobalItem.Rarity5BuyPrice; + item.rare = 5; + item.Calamity().customRarity = CalamityRarity.Dedicated; + } + + public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().dodgeScarf; + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.dodgeScarf = true; + modPlayer.deflectionScarf = true; + modPlayer.dashMod = 1; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.SoulofMight, 5); + recipe.AddIngredient(ItemID.SoulofSight, 5); + recipe.AddIngredient(ItemID.SoulofFright, 5); + recipe.AddIngredient(ItemID.Silk, 15); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 2177191869..0801ce7587 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -817,7 +817,9 @@ namespace CalamityMod.Items { if (!Collision.SolidCollision(teleportLocation, player.width, player.height)) { - if (modPlayer.scarfCooldown) + if (modPlayer.dScarfCooldown) + player.AddBuff(BuffID.ChaosState, (int)(CalamityPlayer.chaosStateDuration * 1.5), true); + else if (modPlayer.scarfCooldown) player.AddBuff(BuffID.ChaosState, CalamityPlayer.chaosStateDuration * 2, true); else player.AddBuff(BuffID.ChaosState, CalamityPlayer.chaosStateDuration, true);