diff --git a/Content/DecimationPlayer.cs b/Content/DecimationPlayer.cs index bd60bcb..76f9098 100644 --- a/Content/DecimationPlayer.cs +++ b/Content/DecimationPlayer.cs @@ -70,6 +70,7 @@ namespace Decimation.Content public ICollection EquippedAccessories { get; } = new List(); public bool HasShield { get; set; } + public bool NextHitCrit { get; set; } public Item AmuletSlotItem { @@ -403,6 +404,44 @@ namespace Decimation.Content } } + public override void ModifyHitNPC(Item item, NPC target, ref int damage, ref float knockback, ref bool crit) + { + if (NextHitCrit) + { + crit = true; + NextHitCrit = false; + } + } + + public override void ModifyHitNPCWithProj(Projectile proj, NPC target, ref int damage, ref float knockback, + ref bool crit, + ref int hitDirection) + { + if (NextHitCrit) + { + crit = true; + NextHitCrit = false; + } + } + + public override void ModifyHitPvp(Item item, Player target, ref int damage, ref bool crit) + { + if (NextHitCrit) + { + crit = true; + NextHitCrit = false; + } + } + + public override void ModifyHitPvpWithProj(Projectile proj, Player target, ref int damage, ref bool crit) + { + if (NextHitCrit) + { + crit = true; + NextHitCrit = false; + } + } + public override void ModifyHitByNPC(NPC npc, ref int damage, ref bool crit) { _amuletSlotAmulet?.Synergy.OnPlayerHit(this, ref damage); diff --git a/Content/Items/Accessories/Trinity/Body.cs b/Content/Items/Accessories/Trinity/Body.cs index d2ce481..e440a34 100644 --- a/Content/Items/Accessories/Trinity/Body.cs +++ b/Content/Items/Accessories/Trinity/Body.cs @@ -10,9 +10,9 @@ namespace Decimation.Content.Items.Accessories.Trinity protected override string ItemName => "The Body"; protected override string ItemTooltip => "I feel all...\n" + - "Increase maximum life by 50\n" + + "Increases maximum life by 50\n" + "You deal 10% more melee damage\n" + - "Your melee critical hit chances are increase by 10%\n" + + "Your melee critical hit chances are increased by 10%\n" + "Hostile projectiles have 10% chance to ricochet off you\nand target your enemies with 50% increased damage"; protected override void InitAccessory() @@ -92,7 +92,6 @@ namespace Decimation.Content.Items.Accessories.Trinity } if (newTarget == null) return false; - Main.NewText(newTarget.position); float speed = projectile.velocity.Length(); Vector2 velocity = newTarget.Center - projectile.Center; diff --git a/Content/Items/Accessories/Trinity/Soul.cs b/Content/Items/Accessories/Trinity/Soul.cs new file mode 100644 index 0000000..696f5b7 --- /dev/null +++ b/Content/Items/Accessories/Trinity/Soul.cs @@ -0,0 +1,97 @@ +using Decimation.Lib.Util; +using Terraria; +using Terraria.ModLoader; + +namespace Decimation.Content.Items.Accessories.Trinity +{ + public class Soul : TrinityAccessory + { + protected override string ItemName => "The Soul"; + protected override string ItemTooltip => "I am all...\n" + + "Increases maximum mana by 50\n" + + "You deal 10% more magic damage\n" + + "Your magic critical hit chances are increased by 10%\n" + + "Your criticals hits leech mana\n" + + "Hostile projectiles have 10% to phase through you,\nnegating all damage and causing your next attack to be a critical hit"; + + protected override void InitAccessory() + { + item.width = 10; + item.height = 16; + item.expert = true; + item.rare = Rarity.Rainbow.GetRarityValue(); + item.value = Item.sellPrice(gold: 5); + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.statManaMax2 += 50; + player.magicDamage *= 1.10f; + player.magicCrit *= (int) (player.magicCrit * 1.10f); + + base.UpdateAccessory(player, hideVisual); + } + } + + class SoulItemEffects : GlobalItem + { + public override void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit) + { + if (crit && player.GetModPlayer().HasEquippedAccessory(ModContent.ItemType())) + { + player.LeechMana(target); + } + } + + public override void OnHitPvp(Item item, Player player, Player target, int damage, bool crit) + { + if (crit && player.GetModPlayer().HasEquippedAccessory(ModContent.ItemType())) + { + player.LeechMana(target); + } + } + } + + class SoulProjectileEffects : GlobalProjectile + { + public override void OnHitNPC(Projectile projectile, NPC target, int damage, float knockback, bool crit) + { + Player owner = Main.player[projectile.owner]; + if (crit && owner != null && owner.active && !owner.dead && + owner.GetModPlayer().HasEquippedAccessory(ModContent.ItemType())) + { + owner.LeechMana(target); + } + } + + public override void OnHitPvp(Projectile projectile, Player target, int damage, bool crit) + { + Player owner = Main.player[projectile.owner]; + if (crit && owner != null && owner.active && !owner.dead && + owner.GetModPlayer().HasEquippedAccessory(ModContent.ItemType())) + { + owner.LeechMana(target); + } + } + + public override void ModifyHitPvp(Projectile projectile, Player target, ref int damage, ref bool crit) + { + IgnoreHit(target, ref damage); + } + + public override void ModifyHitPlayer(Projectile projectile, Player target, ref int damage, ref bool crit) + { + IgnoreHit(target, ref damage); + } + + private void IgnoreHit(Player target, ref int damage) + { + DecimationPlayer targetModPlayer = target.GetModPlayer(); + if (Main.rand.NextBool(10) && targetModPlayer.HasEquippedAccessory(ModContent.ItemType())) + { + damage = 0; + targetModPlayer.NextHitCrit = true; + } + } + } +} \ No newline at end of file diff --git a/Content/Items/Accessories/Trinity/Soul.png b/Content/Items/Accessories/Trinity/Soul.png new file mode 100644 index 0000000..0d3dce0 Binary files /dev/null and b/Content/Items/Accessories/Trinity/Soul.png differ diff --git a/Content/Items/Accessories/Trinity/TrinityAccessory.cs b/Content/Items/Accessories/Trinity/TrinityAccessory.cs index b730210..92ea381 100644 --- a/Content/Items/Accessories/Trinity/TrinityAccessory.cs +++ b/Content/Items/Accessories/Trinity/TrinityAccessory.cs @@ -1,6 +1,7 @@ using Decimation.Lib.Items; using Decimation.Lib.Util; using Terraria; +using Terraria.ModLoader; namespace Decimation.Content.Items.Accessories.Trinity { @@ -8,7 +9,8 @@ namespace Decimation.Content.Items.Accessories.Trinity { public override bool CanEquipAccessory(Player player, int slot) { - return !player.HasEquippedAccessory(item.type); + return !player.HasEquippedAccessory(ModContent.ItemType()) && + !player.HasEquippedAccessory(ModContent.ItemType()); } } } \ No newline at end of file diff --git a/Lib/Util/PlayerUtils.cs b/Lib/Util/PlayerUtils.cs index 3bc15c0..dbd933d 100644 --- a/Lib/Util/PlayerUtils.cs +++ b/Lib/Util/PlayerUtils.cs @@ -31,5 +31,17 @@ namespace Decimation.Lib.Util { return player.GetModPlayer().AmuletSlotItem.type == amuletType; } + + public static void LeechMana(this Player player, Entity target, int minMana = 5, int maxMana = 15) + { + int manaAmount = Main.rand.Next(minMana, maxMana + 1); + player.ManaEffect(manaAmount); + Main.NewText(manaAmount); + + if (target.GetType() == typeof(Player)) + { + ((Player) target).ManaEffect(-manaAmount); + } + } } } \ No newline at end of file