From 01a4ad3dea199acb5dc007a3f1677248bdc07aad Mon Sep 17 00:00:00 2001 From: FyloZ Date: Mon, 20 Jul 2020 16:06:07 -0400 Subject: [PATCH] Added Titanic Paladin Shield Added Titan Shield --- Content/DecimationPlayer.cs | 24 ++---- Content/Items/Accessories/TitanShield.cs | 56 +++++++++++++ Content/Items/Accessories/TitanShield.png | Bin 0 -> 589 bytes .../Items/Accessories/TitanicPaladinShield.cs | 75 ++++++++++++++++++ .../Accessories/TitanicPaladinShield.png | Bin 0 -> 822 bytes Content/ShieldID.cs | 27 +++++++ Content/Synergies/GraniteAmuletSynergy.cs | 3 +- Lib/Items/DecimationAccessory.cs | 8 +- Lib/Util/PlayerUtils.cs | 44 +++++++++- 9 files changed, 216 insertions(+), 21 deletions(-) create mode 100644 Content/Items/Accessories/TitanShield.cs create mode 100644 Content/Items/Accessories/TitanShield.png create mode 100644 Content/Items/Accessories/TitanicPaladinShield.cs create mode 100644 Content/Items/Accessories/TitanicPaladinShield.png create mode 100644 Content/ShieldID.cs diff --git a/Content/DecimationPlayer.cs b/Content/DecimationPlayer.cs index b0c9ed0..0d3ae01 100644 --- a/Content/DecimationPlayer.cs +++ b/Content/DecimationPlayer.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using Decimation.Content.Buffs.Buffs; using Decimation.Content.Items.Accessories; -using Decimation.Content.Items.Accessories.Trinity; using Decimation.Content.Items.Amulets; using Decimation.Content.Items.Misc; using Decimation.Lib.Amulets; @@ -10,7 +9,6 @@ using Decimation.Lib.Collections; using Decimation.Lib.Util; using Microsoft.Xna.Framework; using Terraria; -using Terraria.GameInput; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -71,7 +69,6 @@ namespace Decimation.Content public bool wasJumping = false; public ICollection EquippedAccessories { get; } = new List(); - public bool HasShield { get; set; } public bool NextHitCrit { get; set; } public Item AmuletSlotItem @@ -103,8 +100,6 @@ namespace Decimation.Content tideTurnerEquipped = false; vampire = false; - HasShield = false; - hasCursedAccessory = false; player.statManaMax2 += hyperStars * HyperStar.ManaHealAmount; @@ -433,6 +428,8 @@ namespace Decimation.Content crit = true; NextHitCrit = false; } + + if (target.TeamHasEquippedAccessory(ModContent.ItemType())) damage -= (int) (damage * 0.35f); } public override void ModifyHitPvpWithProj(Projectile proj, Player target, ref int damage, ref bool crit) @@ -447,11 +444,17 @@ namespace Decimation.Content public override void ModifyHitByNPC(NPC npc, ref int damage, ref bool crit) { _amuletSlotAmulet?.Synergy.OnPlayerHit(this, ref damage); + + if (this.TeamHasEquippedAccessory(ModContent.ItemType())) damage -= (int) (damage * 0.35f); + else if (this.TeamHasEquippedAccessory(ModContent.ItemType())) damage -= (int) (damage * 0.30f); } public override void ModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit) { _amuletSlotAmulet?.Synergy.OnPlayerHit(this, ref damage); + + if (this.TeamHasEquippedAccessory(ModContent.ItemType())) damage -= (int) (damage * 0.35f); + else if (this.TeamHasEquippedAccessory(ModContent.ItemType())) damage -= (int) (damage * 0.30f); } private void SpawnWaspNecklaceWasps() @@ -898,15 +901,4 @@ namespace Decimation.Content } } } - - public class PlayerPropertiesUpdater : GlobalItem - { - public override void UpdateAccessory(Item item, Player player, bool hideVisual) - { - DecimationPlayer modPlayer = player.GetModPlayer(); - if (item.type == ItemID.CobaltShield || item.type == ItemID.AnkhShield || - item.type == ItemID.PaladinsShield || item.type == ItemID.ObsidianShield) modPlayer.HasShield = true; - base.UpdateAccessory(item, player, hideVisual); - } - } } \ No newline at end of file diff --git a/Content/Items/Accessories/TitanShield.cs b/Content/Items/Accessories/TitanShield.cs new file mode 100644 index 0000000..1d953f9 --- /dev/null +++ b/Content/Items/Accessories/TitanShield.cs @@ -0,0 +1,56 @@ +using Decimation.Content.Items.Misc.Souls; +using Decimation.Content.Items.Ores; +using Decimation.Content.Tiles; +using Decimation.Lib.Items; +using Decimation.Lib.Util; +using Decimation.Lib.Util.Builder; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace Decimation.Content.Items.Accessories +{ + public class TitanShield : DecimationAccessory + { + protected override string ItemName => "Titan Shield"; + + protected override string ItemTooltip => "This is ridiculously heavy\n" + + "Increases defense by 10\n" + + "Increases all damages by 8%\n" + + "Increases knockback by 8%\n" + + "Increases all critical hit chances by 8%\n" + + "Absords 35% of damage taken by members of your team"; + + protected override void InitAccessory() + { + item.width = 34; + item.height = 40; + item.defense = 10; + item.value = Item.sellPrice(gold: 87, silver: 66); + item.rare = Rarity.Cyan.GetRarityValue(); + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.allDamage *= 1.08f; + player.meleeCrit = (int) (player.meleeCrit * 1.08f); + player.rangedCrit = (int) (player.rangedCrit * 1.08f); + player.magicCrit = (int) (player.magicCrit * 1.08f); + player.thrownCrit = (int) (player.thrownCrit * 1.08f); + + player.EquipAccessory(ModContent.ItemType()); + } + + protected override ModRecipe GetRecipe() + { + return new RecipeBuilder(this) + .WithIngredient(ModContent.ItemType()) + .WithIngredient(ModContent.ItemType(), 15) + .WithIngredient(ItemID.Ectoplasm, 50) + .WithIngredient(ModContent.ItemType(), 20) + .WithIngredient(ModContent.ItemType(), 15) + .WithStation(ModContent.TileType()) + .Build(); + } + } +} \ No newline at end of file diff --git a/Content/Items/Accessories/TitanShield.png b/Content/Items/Accessories/TitanShield.png new file mode 100644 index 0000000000000000000000000000000000000000..4aae9cf38bc219b63b4bfe4de0dea01d1e649262 GIT binary patch literal 589 zcmV-T0Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0pdwSK~z{r?U+w1 zL}3(%$1HpRO<72k8g`Ow6v@KEf~7xYrDov+_yTtJEXYcU>?{-uDJ#jsj)@{H)Z_!$ z&^hj-+mAc%VBx*xsnc(onY!~n^PV&F-ljr;?t%H&^UeD9(dr#%5`s}$`S@Z-o6rT}HgbbV=-+C@BPkJhQ`xlO2;71|Ae37~tZ5L`bRBi}yhF;nOW zrfT!ijwf)Af&85Gl5F^HfRc6U&m#W20ZD$K9fToJQ=$7Hpl4k@UB+ufQA0l^biR(n bNTKisHylc5aWwpI00000NkvXXu0mjfAzuYK literal 0 HcmV?d00001 diff --git a/Content/Items/Accessories/TitanicPaladinShield.cs b/Content/Items/Accessories/TitanicPaladinShield.cs new file mode 100644 index 0000000..275e2f5 --- /dev/null +++ b/Content/Items/Accessories/TitanicPaladinShield.cs @@ -0,0 +1,75 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Decimation.Content.Tiles; +using Decimation.Lib.Items; +using Decimation.Lib.Util; +using Decimation.Lib.Util.Builder; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace Decimation.Content.Items.Accessories +{ + public class TitanicPaladinShield : DecimationAccessory + { + protected override string ItemName => "Titanic Paladin Shield"; + + protected override string ItemTooltip => "Increases defense by 8\n" + + "Increases all damage by 5%\n" + + "Increases knockback by 50%\n" + + "Enables auto-swing on all melee weapons\n" + + "Absords 30% of damage taken by members of your team"; + + protected override void InitAccessory() + { + item.width = 34; + item.height = 42; + item.defense = 8; + item.value = Item.sellPrice(gold: 20, silver: 60); + item.rare = Rarity.Yellow.GetRarityValue(); + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.allDamage *= 1.05f; + } + + protected override ModRecipe GetRecipe() + { + return new RecipeBuilder(this) + .WithIngredient(ItemID.PaladinsShield) + .WithIngredient(ItemID.TitanGlove) + .WithIngredient(ItemID.SoulofNight, 15) + .WithIngredient(ItemID.SoulofLight, 15) + .WithIngredient(ItemID.SoulofMight, 15) + .WithStation(ModContent.TileType()) + .Build(); + } + } + + class TitanicPaladinShieldItemEffect : GlobalItem + { + private static readonly Dictionary OriginalAutoswingState = new Dictionary(); + + public override void SetDefaults(Item item) + { + OriginalAutoswingState[item.type] = item.autoReuse; + } + + public override void GetWeaponKnockback(Item item, Player player, ref float knockback) + { + if (player.HasEquippedAccessory(ModContent.ItemType())) + { + knockback *= 1.5f; + + if (item.melee && !OriginalAutoswingState[item.type]) + item.autoReuse = true; + } + else + { + if (item.autoReuse && !OriginalAutoswingState[item.type]) + item.autoReuse = false; + } + } + } +} \ No newline at end of file diff --git a/Content/Items/Accessories/TitanicPaladinShield.png b/Content/Items/Accessories/TitanicPaladinShield.png new file mode 100644 index 0000000000000000000000000000000000000000..40e7aa3941d36a14a5432154b7509c31f56126ea GIT binary patch literal 822 zcmV-61Ihe}P)vqUp)92q7hY;! zqQkgAW_igL7b{wX8?2G<@mc=AG_|V@BjHd|CjIceZIfn@99J%zkhS5kNENH z^1;)uQDTKe`@O-BdM5&b`nse9sBcIGgs=*6KQ}S&id)4Q+wVm~M+Bxd8@KARspUjL zEaH0qpd#Lh*gZVk+^SIH=_cXrTUUh#>c$9XRcsF^wQ9pYjW3_sABaEdJf`v9hL6I< zOI8SLH`NH&S62z~SXS1AhKMx=E8TJEil)YmA0;d+og|!CGFtei_ml8dPq*;>yU)U- zyH^TP&c5HNh<73oAe~Wyy=MM(@7e%Y6hI*+CzqTL+=sVN#@45-a_*goi@>$?Jgsbb z;=T|?@J4(3vEoY;GXq{hk#lX+6kk{QOz2W3D{JhQcq2l+fB-8kjx+}LoR#iLZd3eV z>Udz~+}t0j)g{WIEcL~iHK8NIim4keWo)|J?6P$QujH+WcOsZIb?R;)8_LROYkd7u zraMoWssmkQ!p>sh+avwLmoGB@U$#2az1wfz5TZ&;N5B@lJ#uff5k1J%_qM zT_KfnJ)d`F&GjNaSTG`dAQoGoOP3PX3)VYU8I(i`=5wA|y%B*SCpCz~V_llU1Dw#( z9ZwXeJ5xCm@fnJ9LSyTAf6K)Wy3G5`8X6+h6IKFpa^uvFGAKcpr6t(sZMHD)JjHt_ zV!dK3E%VkJc1#7uBQ9?^6$u>?7a>;I(G|1Xud&TCmnZDQIsdpLo!KI9M65E5U1oMw z&cDj{M=+-%p(A2fWdB99y(5(); + public static readonly int TitanicPaladinShield = ModContent.ItemType(); + + public static readonly List Shields = new List + { + CobaltShield, + AnkhShield, + PaladinsShield, + ObsidianShield, + TitanShield, + TitanicPaladinShield + }; + } +} \ No newline at end of file diff --git a/Content/Synergies/GraniteAmuletSynergy.cs b/Content/Synergies/GraniteAmuletSynergy.cs index 76c475c..3d72d24 100644 --- a/Content/Synergies/GraniteAmuletSynergy.cs +++ b/Content/Synergies/GraniteAmuletSynergy.cs @@ -1,4 +1,5 @@ using Decimation.Lib.Amulets.Synergy; +using Decimation.Lib.Util; using Microsoft.Xna.Framework; using Terraria; @@ -8,7 +9,7 @@ namespace Decimation.Content.Synergies { public override void OnPlayerHit(DecimationPlayer modPlayer, ref int damages) { - if (modPlayer.HasShield && Main.rand.NextBool(10)) + if (modPlayer.HasEquippedShield() && Main.rand.NextBool(10)) { damages = 0; CombatText.NewText(modPlayer.player.getRect(), Color.MediumPurple, "Blocked"); diff --git a/Lib/Items/DecimationAccessory.cs b/Lib/Items/DecimationAccessory.cs index bef6db6..387add8 100644 --- a/Lib/Items/DecimationAccessory.cs +++ b/Lib/Items/DecimationAccessory.cs @@ -1,5 +1,6 @@ using Decimation.Lib.Util; using Terraria; +using Terraria.ModLoader; namespace Decimation.Lib.Items { @@ -14,10 +15,13 @@ namespace Decimation.Lib.Items InitAccessory(); } + } - public override void UpdateAccessory(Player player, bool hideVisual) + class AddAccessoriesToPlayerAccessoryList : GlobalItem + { + public override void UpdateAccessory(Item item, Player player, bool hideVisual) { - player.EquipAccessory(this); + player.EquipAccessory(item); } } } \ No newline at end of file diff --git a/Lib/Util/PlayerUtils.cs b/Lib/Util/PlayerUtils.cs index 9d3df3e..644c10f 100644 --- a/Lib/Util/PlayerUtils.cs +++ b/Lib/Util/PlayerUtils.cs @@ -1,3 +1,4 @@ +using System.Linq; using Decimation.Content; using Decimation.Lib.Items; using Terraria; @@ -14,7 +15,17 @@ namespace Decimation.Lib.Util public static void EquipAccessory(this Player player, DecimationAccessory accessory) { - player.GetModPlayer().EquippedAccessories.Add(accessory.item.type); + player.EquipAccessory(accessory.item); + } + + public static void EquipAccessory(this Player player, Item accessory) + { + player.EquipAccessory(accessory.type); + } + + public static void EquipAccessory(this Player player, int item) + { + player.GetModPlayer().EquippedAccessories.Add(item); } public static bool HasEquippedAccessory(this Player player, int accessoryType) @@ -24,7 +35,7 @@ namespace Decimation.Lib.Util public static bool HasEquippedAccessory(this ModPlayer modPlayer, int accessoryType) { - return modPlayer.player.GetModPlayer().EquippedAccessories.Contains(accessoryType); + return modPlayer.player.HasEquippedAccessory(accessoryType); } public static bool HasEquippedAmulet(this Player player, int amuletType) @@ -32,6 +43,35 @@ namespace Decimation.Lib.Util return player.GetModPlayer().AmuletSlotItem.type == amuletType; } + public static bool HasEquippedShield(this Player player) + { + return ShieldID.Shields.Count(player.HasEquippedAccessory) != 0; + } + + public static bool HasEquippedShield(this ModPlayer modPlayer) + { + return modPlayer.player.HasEquippedShield(); + } + + public static bool TeamHasEquippedAccessory(this Player player, int accessoryType) + { + for (int i = 0; i < Main.player.Length; i++) + { + Player p = Main.player[i]; + if (p.active && !p.dead && p.team == player.team && p.HasEquippedAccessory(accessoryType)) + { + return true; + } + } + + return false; + } + + public static bool TeamHasEquippedAccessory(this ModPlayer modPlayer, int accessoryType) + { + return modPlayer.player.TeamHasEquippedAccessory(accessoryType); + } + public static void LeechMana(this Player player, Entity target, int minMana = 5, int maxMana = 15) { int manaAmount = Main.rand.Next(minMana, maxMana + 1);