diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index a5bba7afaf..27b0a99fd2 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -5775,7 +5775,7 @@ namespace CalamityMod.CalPlayer bool victideBreastplateVisible = Player.body == EquipLoader.GetEquipSlot(Mod, "VictideBreastplate", EquipType.Body); //Give the player faulds if either the body armor or the leggings are equipped - if (victideBreastplateVisible || Player.legs == EquipLoader.GetEquipSlot(Mod, "VictideLeggings", EquipType.Legs)) + if (victideBreastplateVisible || Player.legs == EquipLoader.GetEquipSlot(Mod, "VictideGreaves", EquipType.Legs)) { Player.waist = (sbyte)EquipLoader.GetEquipSlot(Mod, "VictideFaulds", EquipType.Waist); diff --git a/Items/Weapons/Melee/RedtideSpear.cs b/Items/Weapons/Melee/RedtideSpear.cs index e0c313bb9d..93cbecfe05 100644 --- a/Items/Weapons/Melee/RedtideSpear.cs +++ b/Items/Weapons/Melee/RedtideSpear.cs @@ -12,7 +12,9 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Redtide Spear"); - Tooltip.SetDefault("Poisons enemies and fires short-range stingers"); + Tooltip.SetDefault("Poisons enemies on hit\n"+ + "Aiming the spear in front of you while running holds it down with increased knockback\n"+ + "Releasing the attack button after the charge makes an upwards slash, sending enemies flying into the air"); SacrificeTotal = 1; } @@ -29,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.channel = true; Item.useTime = 25; Item.knockBack = 5f; - Item.UseSound = SoundID.Item1; + Item.UseSound = null; Item.autoReuse = true; Item.height = 56; Item.value = Item.buyPrice(0, 2, 0, 0); diff --git a/Items/Weapons/Ranged/ReedBlowgun.cs b/Items/Weapons/Ranged/ReedBlowgun.cs index 69ab52d5ce..0e5037ca48 100644 --- a/Items/Weapons/Ranged/ReedBlowgun.cs +++ b/Items/Weapons/Ranged/ReedBlowgun.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - Item.damage = 12; + Item.damage = 19; Item.DamageType = DamageClass.Ranged; Item.width = 22; Item.height = 46; diff --git a/NPCs/CalamityFallDamageNPC.cs b/NPCs/CalamityFallDamageNPC.cs new file mode 100644 index 0000000000..06f765a85e --- /dev/null +++ b/NPCs/CalamityFallDamageNPC.cs @@ -0,0 +1,174 @@ +using CalamityMod.Buffs; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatBuffs; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using CalamityMod.Events; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Tools; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs.Abyss; +using CalamityMod.NPCs.AdultEidolonWyrm; +using CalamityMod.NPCs.AcidRain; +using CalamityMod.NPCs.AquaticScourge; +using CalamityMod.NPCs.Astral; +using CalamityMod.NPCs.AstrumDeus; +using CalamityMod.NPCs.Bumblebirb; +using CalamityMod.NPCs.Calamitas; +using CalamityMod.NPCs.CeaselessVoid; +using CalamityMod.NPCs.Crabulon; +using CalamityMod.NPCs.Crags; +using CalamityMod.NPCs.DesertScourge; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.DraedonLabThings; +using CalamityMod.NPCs.ExoMechs.Apollo; +using CalamityMod.NPCs.ExoMechs.Artemis; +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.NPCs.Leviathan; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.Perforator; +using CalamityMod.NPCs.PlagueEnemies; +using CalamityMod.NPCs.Polterghast; +using CalamityMod.NPCs.ProfanedGuardians; +using CalamityMod.NPCs.Providence; +using CalamityMod.NPCs.Ravager; +using CalamityMod.NPCs.SlimeGod; +using CalamityMod.NPCs.StormWeaver; +using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.Particles; +using CalamityMod.Projectiles; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Typeless; +using CalamityMod.UI; +using CalamityMod.Walls.DraedonStructures; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.GameContent.Achievements; +using Terraria.GameContent.Events; +using Terraria.Graphics.Effects; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; +using static Terraria.ModLoader.ModContent; +using CalamityMod.NPCs.ExoMechs; +using CalamityMod.NPCs.VanillaNPCOverrides.Bosses; +using CalamityMod.NPCs.VanillaNPCOverrides.RegularEnemies; +using CalamityMod.Balancing; +using Terraria.GameContent; +using CalamityMod.Systems; +using Terraria.ModLoader.Utilities; + +namespace CalamityMod.NPCs +{ + public class CalamityFallDamageNPC : GlobalNPC + { + /// + /// How much "gravity damage" is this npc slated to recieve once it hits the ground. + /// + private int potentialEnergyDamage = 0; + /// + /// This keeps track of the last recorded vertical velocity, so that we can dispel the potential fall damage if the enemy slows their fall down by any means + /// + private float lastRecordedVerticalVelocity = 0; + /// + /// This keeps track of the last recorded vertical velocity, because terraria is dumb and we need two of them + /// + private float previousLastRecordedVerticalVelocity = 0; + private float terminalVelocityForFullFallDamage = 0; + + public int PotentialEnergyDamage + { + get + { + return potentialEnergyDamage; + } + + private set + { + //You can't stack gravity damage. Higher "gravity" simply replaces the gravity damage. + potentialEnergyDamage = value == 0 ? 0 : Math.Max(potentialEnergyDamage, value); + } + } + + public bool FallDamageSusceptible => PotentialEnergyDamage > 0; + + public override bool InstancePerEntity => true; + + public override GlobalNPC Clone(NPC npc, NPC npcClone) + { + CalamityFallDamageNPC myClone = (CalamityFallDamageNPC)base.Clone(npc, npcClone); + + myClone.potentialEnergyDamage = potentialEnergyDamage; + myClone.lastRecordedVerticalVelocity = lastRecordedVerticalVelocity; + myClone.previousLastRecordedVerticalVelocity = previousLastRecordedVerticalVelocity; + myClone.terminalVelocityForFullFallDamage = terminalVelocityForFullFallDamage; + + return myClone; + } + + public override void SetDefaults(NPC npc) + { + PotentialEnergyDamage = 0; + lastRecordedVerticalVelocity = 0f; + } + + /// + /// Sets up a NPC to recieve fall damage when they hit the ground. + /// + /// The npc to apply fall damage to + /// The maximum fall damage taken by the npc once they hit the ground + /// The downwards velocity necessary to recieve the full fall damage. By default 10, the npc max fall speed + public void ApplyFallDamage(NPC npc, int potentialDamage, float terminalVelocityForFullDamage = 10f) + { + //NPCs that don't collide with tiles simply don't get fall damage, lol. + if (npc.noTileCollide) + return; + + PotentialEnergyDamage = potentialDamage; + lastRecordedVerticalVelocity = npc.velocity.Y; + previousLastRecordedVerticalVelocity = npc.velocity.Y; + terminalVelocityForFullFallDamage = terminalVelocityForFullDamage; + } + + public override void PostAI(NPC npc) + { + if (FallDamageSusceptible) + { + float newVerticalVelocity = npc.velocity.Y; + + //If the thing flies back up, cancel the fall dmg + if (newVerticalVelocity < 0 && lastRecordedVerticalVelocity >= 0) + PotentialEnergyDamage = 0; + + //Same goes for if it slows its fall. + //We use 3 variables cuz there is a frame inbetween the fall and the landing where the velocity is still set to something. + if (newVerticalVelocity > 0 && previousLastRecordedVerticalVelocity > 0 && lastRecordedVerticalVelocity < previousLastRecordedVerticalVelocity) + PotentialEnergyDamage = 0; + + //If the npc hit a tile/Came to a stop after falling + if (newVerticalVelocity == 0 && lastRecordedVerticalVelocity > 0) + { + //I don't think a tile check below the npc is necessary but if we find weird edge cases ill add it + npc.StrikeNPC((int)(PotentialEnergyDamage * Math.Clamp(previousLastRecordedVerticalVelocity / terminalVelocityForFullFallDamage, 0f, 1f)), 0f, 1, fromNet: true); + PotentialEnergyDamage = 0; + } + + previousLastRecordedVerticalVelocity = lastRecordedVerticalVelocity; + lastRecordedVerticalVelocity = newVerticalVelocity; + } + } + } +} diff --git a/Projectiles/Melee/Spears/RedtideSpearProjectile.cs b/Projectiles/Melee/Spears/RedtideSpearProjectile.cs index 79066365c5..9fadc6aa12 100644 --- a/Projectiles/Melee/Spears/RedtideSpearProjectile.cs +++ b/Projectiles/Melee/Spears/RedtideSpearProjectile.cs @@ -7,6 +7,7 @@ using Terraria.Audio; using System; using CalamityMod.Particles; using static CalamityMod.CalamityUtils; +using ReLogic.Utilities; namespace CalamityMod.Projectiles.Melee.Spears { @@ -16,6 +17,19 @@ namespace CalamityMod.Projectiles.Melee.Spears public static int Lifetime = 28; public int Timer => Lifetime - Projectile.timeLeft; + private SlotId ChargeWindSoundSlot; + public ActiveSound ChargeWindSound + { + get + { + ActiveSound sound; + if (SoundEngine.TryGetActiveSound(ChargeWindSoundSlot, out sound)) + return sound; + return null; + } + } + + public int ChargeDirection => Math.Sign(Projectile.velocity.X); #region Thrust @@ -48,8 +62,9 @@ namespace CalamityMod.Projectiles.Melee.Spears public static int MaxRunTime = 300; //Player can only do the run attack while moving fast horizontally in the direction of the thrust, but remaining on the ground - public bool CanRunAttack => Math.Abs(Owner.velocity.Y) <= 0.4f && Math.Abs(Owner.velocity.X) >= Owner.maxRunSpeed * 0.7f && Math.Sign(Owner.velocity.X) == ChargeDirection && Owner.channel && !RunBroken; - public bool CanStartRunAttack => CanRunAttack && (Owner.Calamity().mouseWorld.Y - Owner.Center.Y) > -50; + public bool CanRunAttack => Math.Abs(Owner.velocity.Y) <= 0.8f && Math.Abs(Owner.velocity.X) >= Owner.maxRunSpeed * 0.7f && Math.Sign(Owner.velocity.X) == ChargeDirection && Owner.channel && !RunBroken; + //You can only start a run attack if you meet the other conditions, but ALSO you can't do it if you are aiming too much upwards or downwards + public bool CanStartRunAttack => CanRunAttack && Math.Abs(Owner.Calamity().mouseWorld.Y - Owner.Center.Y) <= 300; public ref float RunTimer => ref Projectile.ai[0]; //The window of time during which the run hasn't fully started, and is indentical to the regular thrust's start. This tells us when we can no longer do this switch. public bool FullyRunning => RunTimer > InitializationTime; @@ -218,23 +233,52 @@ namespace CalamityMod.Projectiles.Melee.Spears if (FullyRunning) { Projectile.timeLeft = UpThrustLifetime; - //Play a sound } } + ActiveSound soundOut; + if (!SoundEngine.TryGetActiveSound(ChargeWindSoundSlot, out soundOut) || !soundOut.IsPlaying) + ChargeWindSoundSlot = SoundEngine.PlaySound(SoundID.DD2_BookStaffTwisterLoop with { IsLooped = true, Volume = SoundID.DD2_BookStaffTwisterLoop.Volume * 0.7f }, Projectile.Center); + + else + { + soundOut.Volume = MathHelper.Lerp(0f, SoundID.DD2_BookStaffTwisterLoop.Volume * 0.7f, Math.Clamp(RunTimer / 120f, 0f, 1f)); + soundOut.Position = Projectile.Center; + } + RunTimer++; + if (Main.rand.NextBool()) + { + int dustOpacity = Main.rand.Next(80); + float dustScale = Main.rand.NextFloat(1f, 1.4f); + Vector2 dustVelocity = (AppropriateRotation + MathHelper.Pi).ToRotationVector2().RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(0.5f, 5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + AppropriateRotation.ToRotationVector2() * 40f, 16, dustVelocity, Alpha: dustOpacity, Scale: dustScale); + } } //Basic spear attack else if (CurrentAttackState == AttackState.ForwardThrust) { - //Play a sound if in the middle of the thrust. + if (ThrustProgress == 0.5f) + SoundEngine.PlaySound(SoundID.DD2_JavelinThrowersAttack, Projectile.Center); } else if (CurrentAttackState == AttackState.UpwardsThrust) { - //Do i even need to do anything here lol + ActiveSound soundOut; + + + if (SoundEngine.TryGetActiveSound(ChargeWindSoundSlot, out soundOut)) + { + soundOut.Volume *= 0.7f; + soundOut.Position = Projectile.Center; + if (soundOut.Volume < 0.2f) + soundOut.Stop(); + } + + if (ThrustProgress == 0.5f) + SoundEngine.PlaySound(SoundID.DD2_MonkStaffSwing, Projectile.Center); } UpdateOwnerVars(); @@ -267,11 +311,16 @@ namespace CalamityMod.Projectiles.Melee.Spears { //Send the enemy flying up if hit by the upwards thrust. if (CurrentAttackState == AttackState.UpwardsThrust) + { target.velocity.Y -= 12 * (float)Math.Sqrt(target.knockBackResist); + target.FallingNPC().ApplyFallDamage(target, 50, 5f); + } target.AddBuff(BuffID.Poisoned, 180); - Owner.GiveIFrames(5); + //Give a sliver of iframes to the player so its safer to ram into hordes (which is fun and should be encouraged) + if (CurrentAttackState == AttackState.RunAttack) + Owner.GiveIFrames(5); } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) diff --git a/Projectiles/Rogue/FishboneBoomerangProjectile.cs b/Projectiles/Rogue/FishboneBoomerangProjectile.cs index fa03e224fd..4ca58d5d68 100644 --- a/Projectiles/Rogue/FishboneBoomerangProjectile.cs +++ b/Projectiles/Rogue/FishboneBoomerangProjectile.cs @@ -204,7 +204,20 @@ namespace CalamityMod.Projectiles.Rogue public void ImpactEffects() { - SoundEngine.PlaySound(SoundID.DD2_SkeletonHurt with { Volume = SoundID.DD2_SkeletonHurt.Volume * 0.8f }, Projectile.Center); + //If the boomerang somehow hits 10 enemies, make it start doing drum sounds + SoundStyle bonkSound = Projectile.numHits < 10 ? SoundID.DD2_SkeletonHurt with { Volume = SoundID.DD2_SkeletonHurt.Volume * 0.8f, Pitch = SoundID.DD2_SkeletonHurt.Pitch + 0.1f * Projectile.numHits } : + Utils.SelectRandom(Main.rand, new SoundStyle[] + { + SoundID.DrumClosedHiHat, + SoundID.DrumCymbal1, + SoundID.DrumCymbal2, + SoundID.DrumKick, + SoundID.DrumTamaSnare, + SoundID.DrumTomHigh, + SoundID.DrumHiHat + }); + + SoundEngine.PlaySound(bonkSound, Projectile.Center); int goreNumber = Main.rand.Next(4); for (int i = 0; i < goreNumber; i++) diff --git a/Utilities/GeneralExtensionUtils.cs b/Utilities/GeneralExtensionUtils.cs index a4b8db2b25..895b51c85f 100644 --- a/Utilities/GeneralExtensionUtils.cs +++ b/Utilities/GeneralExtensionUtils.cs @@ -1,4 +1,4 @@ -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using CalamityMod.Items; using CalamityMod.NPCs; using CalamityMod.Projectiles; @@ -10,6 +10,7 @@ namespace CalamityMod { public static CalamityPlayer Calamity(this Player player) => player.GetModPlayer(); public static CalamityGlobalNPC Calamity(this NPC npc) => npc.GetGlobalNPC(); + public static CalamityFallDamageNPC FallingNPC(this NPC npc) => npc.GetGlobalNPC(); public static CalamityGlobalItem Calamity(this Item item) => item.GetGlobalItem(); public static CalamityGlobalProjectile Calamity(this Projectile proj) => proj.GetGlobalProjectile(); public static Item ActiveItem(this Player player) => Main.mouseItem.IsAir ? player.HeldItem : Main.mouseItem;