From 65d4aa61ba1f43123d4539b128db2bcba0f3eb91 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Fri, 27 Nov 2020 16:38:03 -0500 Subject: [PATCH] Titan Arm now properly yeets enemies at the speed of light. The better Grand Dad --- Items/Weapons/Melee/TitanArm.cs | 58 ++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/Items/Weapons/Melee/TitanArm.cs b/Items/Weapons/Melee/TitanArm.cs index 60573b60d7..021751a491 100644 --- a/Items/Weapons/Melee/TitanArm.cs +++ b/Items/Weapons/Melee/TitanArm.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.NPCs; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,28 +12,66 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Titan Arm"); - Tooltip.SetDefault("Slap Hand but better"); + Tooltip.SetDefault("Slap Hand but better\n" + + "Sends enemies straight to the stars at the speed of light"); } public override void SetDefaults() { item.width = 46; item.height = 58; - item.scale = 1.5f; item.damage = 60; - item.crit += 96; //more knockback huehue + item.scale = 1.5f; + item.knockBack = 20f; //This number doesn't mean anything, but it's not 9001f because that caused bugs. + item.useAnimation = item.useTime = 12; item.melee = true; item.useTurn = true; - item.useAnimation = 12; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 12; - item.knockBack = 9001f; - item.UseSound = SoundID.Item1; item.autoReuse = true; - item.value = Item.buyPrice(0, 60, 0, 0); + item.useStyle = ItemUseStyleID.SwingThrow; + item.UseSound = SoundID.Item1; item.rare = 7; + item.value = CalamityGlobalItem.Rarity7BuyPrice; } + public override void ModifyHitNPC(Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) + { + if (target.knockBackResist <= 0f) + return; + + // Manually doing knockback because it is capped in vanilla. This lets Titan Arm reach its full potential. =D + // This is modified vanilla code from StrikeNPC method in NPC.cs + // Extra Note: Will cause an out of bounds error on enemies that don't despawn and are affected. See Blue Cultist Archer. + float kbAmt = knockBack * 9001f * target.knockBackResist; //That obligatory over 9000 reference + if (crit) + kbAmt *= 1.4f; + if (player.direction < 0 && target.velocity.X > -kbAmt) + { + if (target.velocity.X > 0f) + target.velocity.X -= kbAmt; + target.velocity.X -= kbAmt; + if (target.velocity.X < -kbAmt) + target.velocity.X = -kbAmt; + } + else if (player.direction > 0 && target.velocity.X < kbAmt) + { + if (target.velocity.X < 0f) + target.velocity.X += kbAmt; + target.velocity.X += kbAmt; + if (target.velocity.X > kbAmt) + target.velocity.X = kbAmt; + } + float kbAmtY = target.noGravity ? kbAmt * -0.5f : kbAmt * -0.75f; + if (target.velocity.Y > kbAmtY) + { + target.velocity.Y += kbAmtY; + if (target.velocity.Y < kbAmtY) + target.velocity.Y = kbAmtY; + } + } + + // Boosting crit in SetDefaults along with knockback seemed to severely inflate the reforging price. Guaranteed crits for more knockback. + public override void GetWeaponCrit(Player player, ref int crit) => crit = 100; + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120);