diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 0f160292a4..97ead29ab5 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -371,6 +371,12 @@ namespace CalamityMod.CalPlayer cgn.somaShredApplicator = Player.whoAmI; } + // Similarly, all shots from Animosity are also marked + if (cgp.brimstoneBullets) + { + target.AddBuff(BuffType(), 90); + } + ProjLifesteal(target, proj, damageDone, hit.Crit); ProjOnHit(proj, target.Center, hit.Crit, (target.damage > 5 || target.boss) && !target.SpawnedFromStatue); NPCDebuffs(target, proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), proj.CountsAsClass(), true); diff --git a/Items/Weapons/Ranged/Animosity.cs b/Items/Weapons/Ranged/Animosity.cs index b94390e7a6..dd022bb618 100644 --- a/Items/Weapons/Ranged/Animosity.cs +++ b/Items/Weapons/Ranged/Animosity.cs @@ -3,14 +3,29 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Audio; +using static CalamityMod.CalamityUtils; +using CalamityMod.Projectiles; +using System; namespace CalamityMod.Items.Weapons.Ranged { public class Animosity : ModItem, ILocalizedModType { + public static readonly SoundStyle ShootAndReloadSound = new("CalamityMod/Sounds/Item/WulfrumBlunderbussFireAndReload") { PitchVariance = 0.2f }; // Very cool sound and it would be a shame for it to not be used elsewhere + + // If stuff is here then DragonLens can easily detect it so it can change it for balancing + private static float ShotgunBulletSpeed = 11.5f; + private static float SniperBulletSpeed = 15f; + private static float SniperDmgMult = 5.8f; public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetStaticDefaults() { + //DisplayName.SetDefault("Animosity"); + //Tooltip.SetDefault(@"Fires a powerful shotgun blast +//Right click to fire a powerful brimstone round +//All bullets fired from this gun are imbued with Brimstone Flames"); +// These are temporary til I fix the localization ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; } @@ -20,21 +35,26 @@ namespace CalamityMod.Items.Weapons.Ranged Item.DamageType = DamageClass.Ranged; Item.width = 70; Item.height = 18; - Item.useTime = 4; - Item.reuseDelay = 15; - Item.useAnimation = 12; + Item.scale = 0.85f; + Item.useTime = 15; + Item.reuseDelay = 10; + Item.useAnimation = 15; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 2f; Item.value = CalamityGlobalItem.Rarity7BuyPrice; Item.rare = ItemRarityID.Lime; - Item.UseSound = SoundID.Item31; + Item.UseSound = ShootAndReloadSound; Item.autoReuse = true; Item.shoot = ProjectileID.PurificationPowder; - Item.shootSpeed = 11f; + Item.shootSpeed = ShotgunBulletSpeed; Item.useAmmo = AmmoID.Bullet; + Item.crit = -18; // Explained later Item.Calamity().canFirePointBlankShots = true; } + + // Terraria dislikes high crit on SetDefaults + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 20; // 6% Shotgun mode, 32% Sniper Mode. This is after dealing with vanilla adding 4% more public override Vector2? HoldoutOffset() { @@ -50,44 +70,112 @@ namespace CalamityMod.Items.Weapons.Ranged { if (player.altFunctionUse == 2) { - Item.useTime = 4; - Item.reuseDelay = 13; - Item.useAnimation = 12; - Item.UseSound = SoundID.Item31; - Item.shootSpeed = 10f; + Item.useTime = 40; + Item.reuseDelay = 0; + Item.useAnimation = 40; + Item.shootSpeed = SniperBulletSpeed; + Item.crit = 8; } else { - Item.useTime = 35; - Item.reuseDelay = 0; - Item.useAnimation = 35; - Item.UseSound = SoundID.Item40; - Item.shootSpeed = 15f; + Item.useTime = 18; + Item.reuseDelay = 8; + Item.useAnimation = 18; + Item.shootSpeed = ShotgunBulletSpeed; + Item.crit = -18; } return base.CanUseItem(player); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { + if (Main.netMode != NetmodeID.Server) + { + // TO DO: Replace with actual bullet shells, surprised no one has even tried this + Gore.NewGore(source, position, velocity * Main.rand.NextFloat(-0.15f,-0.35f), Mod.Find("Polt5").Type); + } + if (player.altFunctionUse == 2) { - float SpeedX = velocity.X + (float)Main.rand.Next(-10, 11) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-10, 11) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); - return false; + // It should feel powerful but less than the shotgun + if (player.Calamity().GeneralScreenShakePower < 3f) + player.Calamity().GeneralScreenShakePower = 1.5f; + //Shoot from muzzle + Vector2 baseVelocity = velocity.SafeNormalize(Vector2.Zero) * SniperBulletSpeed; + Vector2 nuzzlePos = player.MountedCenter + baseVelocity * 4f; + + + // TO DO: Make a custom big explosive bullet, it should actually look like a bullet being fired and not a line or whatever I'm using as a placeholder + Projectile shot = Projectile.NewProjectileDirect(source, nuzzlePos, velocity, ProjectileID.RocketI, (int)(damage * SniperDmgMult), knockback, player.whoAmI, 0f, 0f); + CalamityGlobalProjectile cgp = shot.Calamity(); + cgp.supercritHits = 1; + cgp.brimstoneBullets = true; + } else { - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, ProjectileID.BulletHighVelocity, (int)(damage * 5.8f), knockback, player.whoAmI, 0f, 0f); - return false; + // It should feel powerful + if (player.Calamity().GeneralScreenShakePower < 3f) + player.Calamity().GeneralScreenShakePower = 3f; + + //Shoot from muzzle + Vector2 baseVelocity = velocity.SafeNormalize(Vector2.Zero) * ShotgunBulletSpeed; + Vector2 nuzzlePos = player.MountedCenter + baseVelocity * 4f; + + // Fire a shotgun spread of bullets. + for (int i = 0; i < 6; ++i) + { + float dx = Main.rand.NextFloat(-1.3f, 1.3f); + float dy = Main.rand.NextFloat(-1.3f, 1.3f); + Vector2 randomVelocity = baseVelocity + new Vector2(dx, dy); + Projectile shot = Projectile.NewProjectileDirect(source, nuzzlePos, randomVelocity, type, damage, knockback, player.whoAmI); + CalamityGlobalProjectile cgp = shot.Calamity(); + cgp.brimstoneBullets = true; + } } + return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) + // Animation zone + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + + public override void UseStyle(Player player, Rectangle heldItemFrame) { - if (Main.rand.Next(0, 100) < 50) - return false; - return true; + // Only the shotgun gets upwards recoil + if (player.altFunctionUse != 2) + { + player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; + + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 35f; + Vector2 itemSize = new Vector2(Item.width, Item.height); + Vector2 itemOrigin = new Vector2(-5, 6); + + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); + base.UseStyle(player, heldItemFrame); + } + // TO DO: Make Sniper have horizontal recoil + } + + // Recoil + Not having the gun aim downwards + public override void UseItemFrame(Player player) + { + player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + + float animProgress = 1 - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + rotation += -0.45f * (float)Math.Pow((1f - animProgress), 2) * player.direction; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); + + //Reloads the gun + if (animProgress < 0.4f) + { + float backArmRotation = rotation + 0.52f * player.direction; + + Player.CompositeArmStretchAmount stretch = ((float)Math.Sin(MathHelper.Pi * (animProgress - 0.5f) / 0.36f)).ToStretchAmount(); + player.SetCompositeArmBack(true, stretch, backArmRotation); + } } } } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index b122e7d8e4..5033164dd4 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -8,6 +8,7 @@ using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.NPCs; using CalamityMod.Particles; +using CalamityMod.Projectiles; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; @@ -57,7 +58,7 @@ namespace CalamityMod.Projectiles // For every 100% critical strike chance over 100%, "supercrit" projectiles do a guaranteed +100% damage. // They then take the remainder (e.g. the remaining 16%) and roll against that for a final +100% (like normal crits). // For example if you have 716% critical strike chance, you are guaranteed +700% damage and then have a 16% chance for +800% damage instead. - // These are currently only enabled for Soma Prime, but any bullet fired from that gun can supercrit. + // Examples of these are Soma Prime and Animosity's sniper mode, but any bullet fired from that gun can supercrit when this bool is activated. // Set this to -1 if you want the projectile to supercrit forever, and to any positive value to make it supercrit only x times public int supercritHits = 0; @@ -71,6 +72,9 @@ namespace CalamityMod.Projectiles // If true, this projectile can apply the infinitely-stacking Shred debuff iconic to Soma Prime. public bool appliesSomaShred = false; + // Adds Brimstone flames to bullets, currently only used by Animosity + public bool brimstoneBullets = false; + // If true, this projectile creates impact sparks upon hitting enemies public bool deepcoreBullet = false; @@ -2020,6 +2024,7 @@ namespace CalamityMod.Projectiles { Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); + CalamityGlobalProjectile cgp = projectile.Calamity(); // In case for marked projectiles like Soma Prime or Animosity so that we can add dusts or some other stuff to them if (!frameOneHacksExecuted) { @@ -2438,6 +2443,18 @@ namespace CalamityMod.Projectiles } } } + if (cgp.brimstoneBullets) + { + for (int flames = 0; flames < 3; flames++) + { + Dust fireTrail = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.Brimstone, projectile.velocity.X, projectile.velocity.Y, 100, default, 1f)]; + fireTrail.velocity = Vector2.Zero; + fireTrail.position -= projectile.velocity / 5f * (float)flames; + fireTrail.noGravity = true; + fireTrail.scale = 1f; + fireTrail.noLight = true; + } + } } } #endregion