diff --git a/CalamityMod.cs b/CalamityMod.cs index b8b00b3fdf..af1402ed87 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -1866,7 +1866,8 @@ namespace CalamityMod ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType() + ModContent.ItemType(), + ModContent.ItemType() }; boomerangList = new List() diff --git a/Items/Weapons/Ranged/TyrannysEnd.cs b/Items/Weapons/Ranged/TyrannysEnd.cs new file mode 100644 index 0000000000..8a5e72f6d8 --- /dev/null +++ b/Items/Weapons/Ranged/TyrannysEnd.cs @@ -0,0 +1,63 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Ranged; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class TyrannysEnd : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tyranny's End"); + Tooltip.SetDefault("Pierce the heart of even the most heavily-armored foe\n" + + "Fires a .70 caliber sniper round that bypasses enemy defense and DR\n" + + "Rounds mark enemies for death and summon a swarm of additional bullets on crits"); + } + + public override void SetDefaults() + { + item.damage = 4000; + item.crit += 35; + item.knockBack = 9.5f; + item.ranged = true; + item.useTime = 55; + item.useAnimation = 55; + item.shoot = ProjectileID.BulletHighVelocity; + item.shootSpeed = 12f; + item.useAmmo = AmmoID.Bullet; + item.autoReuse = true; + + item.width = 94; + item.height = 32; + item.useStyle = 5; + item.noMelee = true; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"); + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Dedicated; + } + + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + } +} diff --git a/Projectiles/Ranged/PiercingBullet.cs b/Projectiles/Ranged/PiercingBullet.cs new file mode 100644 index 0000000000..29d5803af7 --- /dev/null +++ b/Projectiles/Ranged/PiercingBullet.cs @@ -0,0 +1,101 @@ +using CalamityMod.Buffs.StatDebuffs; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Ranged +{ + public class PiercingBullet : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Piercing Blow"); + } + + public override void SetDefaults() + { + projectile.width = 4; + projectile.height = 4; + projectile.light = 0.5f; + projectile.alpha = 255; + projectile.extraUpdates = 10; + projectile.scale = 1.18f; + projectile.friendly = true; + projectile.ranged = true; + projectile.ignoreWater = true; + projectile.aiStyle = 1; + aiType = ProjectileID.BulletHighVelocity; + projectile.penetrate = 1; + projectile.timeLeft = 600; + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + //Avoid touching things that you probably aren't meant to damage + if (target.defense > 999 || target.Calamity().DR >= 0.95f || target.Calamity().unbreakableDR) + return; + + //DR applies after defense, so undo it first + damage = (int)(damage * (1 / (1 - target.Calamity().DR))); + + //Then proceed to ignore all defense + int penetratableDefense = Math.Max(target.defense - Main.player[projectile.owner].armorPenetration, 0); + int penetratedDefense = Math.Min(penetratableDefense, target.defense); + damage += (int)(0.5f * penetratedDefense); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); + Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); + return true; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (crit) + { + int bulletCount = 10; + for (int x = 0; x < bulletCount; x++) + { + float speed = 12f; + float xPos = projectile.Center.X + (x < bulletCount / 2 ? 500f : -500f); + float yPos = projectile.Center.Y + Main.rand.Next(-500, 501); + Vector2 origin = new Vector2(xPos, yPos); + Vector2 velocity = new Vector2(target.Center.X - origin.X, target.Center.Y - origin.Y); + velocity.Normalize(); + velocity *= speed; + if (projectile.owner == Main.myPlayer) + { + Projectile.NewProjectile(origin, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), projectile.knockBack, projectile.owner); + } + } + } + target.AddBuff(ModContent.BuffType(), 900); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + if (crit) + { + int bulletCount = 10; + for (int x = 0; x < bulletCount; x++) + { + float speed = 12f; + float xPos = projectile.Center.X + (x < bulletCount / 2 ? 500f : -500f); + float yPos = projectile.Center.Y + Main.rand.Next(-500, 501); + Vector2 origin = new Vector2(xPos, yPos); + Vector2 velocity = new Vector2(target.Center.X - origin.X, target.Center.Y - origin.Y); + velocity.Normalize(); + velocity *= speed; + if (projectile.owner == Main.myPlayer) + { + Projectile.NewProjectile(origin, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), projectile.knockBack, projectile.owner); + } + } + } + target.AddBuff(ModContent.BuffType(), 900); + } + } +} diff --git a/Projectiles/Ranged/PiercingBullet.png b/Projectiles/Ranged/PiercingBullet.png new file mode 100644 index 0000000000..3f761a0306 Binary files /dev/null and b/Projectiles/Ranged/PiercingBullet.png differ