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 0000000..4aae9cf Binary files /dev/null and b/Content/Items/Accessories/TitanShield.png differ 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 0000000..40e7aa3 Binary files /dev/null and b/Content/Items/Accessories/TitanicPaladinShield.png differ diff --git a/Content/ShieldID.cs b/Content/ShieldID.cs new file mode 100644 index 0000000..989b794 --- /dev/null +++ b/Content/ShieldID.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using Decimation.Content.Items.Accessories; +using Terraria.ID; +using Terraria.ModLoader; + +namespace Decimation.Content +{ + public class ShieldID + { + public const int CobaltShield = ItemID.CobaltShield; + public const int AnkhShield = ItemID.AnkhShield; + public const int PaladinsShield = ItemID.PaladinsShield; + public const int ObsidianShield = ItemID.ObsidianShield; + public static readonly int TitanShield = ModContent.ItemType(); + 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);