diff --git a/Items/Weapons/Melee/GrandDad.cs b/Items/Weapons/Melee/GrandDad.cs new file mode 100644 index 0000000000..4f7bfc462d --- /dev/null +++ b/Items/Weapons/Melee/GrandDad.cs @@ -0,0 +1,51 @@ +using CalamityMod.Items.BaseItems; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Ores; +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Melee; +using CalamityMod.Rarities; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class GrandDad : CustomUseProjItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Melee"; + public override void SetDefaults() + { + Item.width = 124; + Item.height = 124; + Item.damage = 7777; + Item.DamageType = DamageClass.Melee; + Item.useAnimation = 77; + Item.useStyle = ItemUseStyleID.Swing; + Item.useTime = 77; + Item.useTurn = true; + Item.knockBack = 7f; + Item.autoReuse = true; + Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; + Item.rare = ModContent.RarityType(); + + Item.channel = true; + Item.shoot = ModContent.ProjectileType(); + Item.noUseGraphic = true; + Item.noMelee = true; + Item.useStyle = ItemUseStyleID.Shoot; + } + + public override bool MeleePrefix() => true; + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(8). + AddTile(). + Register(); + } + } +} diff --git a/Items/Weapons/Melee/GrandDad.png b/Items/Weapons/Melee/GrandDad.png new file mode 100644 index 0000000000..09d8d4c91b Binary files /dev/null and b/Items/Weapons/Melee/GrandDad.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index 4849d0d582..216522badd 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -634,6 +634,18 @@ GoldplumeSpear: { Tooltip: Shoots falling feathers } +GrandDad: { + DisplayName: Grand Dad + Tooltip: + ''' + A high quality blade that rips through enemies + Striking weaker enemies will launch them with incredible force + Launched enemies take immense damage when colliding with walls and floors + Holding will heavily reduce the damage of the blade and increase its launch damage and velocity + 'Please read the weapon description.' + ''' +} + GrandGuardian: { DisplayName: Grand Guardian Tooltip: diff --git a/NPCs/CalamityFallDamageNPC.cs b/NPCs/CalamityFallDamageNPC.cs index d12bcbd74d..1e2553d890 100644 --- a/NPCs/CalamityFallDamageNPC.cs +++ b/NPCs/CalamityFallDamageNPC.cs @@ -20,6 +20,8 @@ namespace CalamityMod.NPCs /// private Vector2 OlderVelocity = Vector2.Zero; private float terminalVelocityForFullFallDamage = 0; + private bool CheckTiles = false; + private Vector2 ForcedVel = Vector2.Zero; public int PotentialEnergyDamage { @@ -64,7 +66,8 @@ namespace CalamityMod.NPCs /// 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) + /// Will check for tiles in the collision instead of velocity + public void ApplyFallDamage(NPC npc, int potentialDamage, Vector2 forcedVel, float terminalVelocityForFullDamage = 10f, bool checkTiles = false) { //NPCs that don't collide with tiles simply don't get fall damage, lol. if (npc.noTileCollide) @@ -74,35 +77,54 @@ namespace CalamityMod.NPCs OldVelocity = npc.velocity; OlderVelocity = npc.velocity; terminalVelocityForFullFallDamage = terminalVelocityForFullDamage; + CheckTiles = checkTiles; + ForcedVel = forcedVel; } public override void PostAI(NPC npc) { if (FallDamageSusceptible) { - float newVerticalVelocity = npc.velocity.Y; - float oldVerticalVelocity = OldVelocity.Y; - float olderVerticalVelocity = OlderVelocity.Y; - - //If the thing flies back up, cancel the fall dmg - if (newVerticalVelocity < 0 && oldVerticalVelocity >= 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 && olderVerticalVelocity > 0 && oldVerticalVelocity < olderVerticalVelocity) - PotentialEnergyDamage = 0; - - //If the npc hit a tile/Came to a stop after falling - if (newVerticalVelocity == 0 && oldVerticalVelocity > 0) + if (CheckTiles) { - //I don't think a tile check below the npc is necessary but if we find weird edge cases ill add it - npc.StrikeNPC(npc.CalculateHitInfo((int)(PotentialEnergyDamage * Math.Clamp(olderVerticalVelocity / terminalVelocityForFullFallDamage, 0f, 1f)), 1), true); - PotentialEnergyDamage = 0; - } + float oldVelocity = OldVelocity.Length(); - OlderVelocity = OldVelocity; - OldVelocity = npc.velocity; + if (Collision.SolidCollision(npc.Center, (int)(npc.width * 0.5f), (int)(npc.height * 0.5f))) + { + npc.StrikeNPC(npc.CalculateHitInfo((int)(PotentialEnergyDamage * Math.Clamp(oldVelocity / terminalVelocityForFullFallDamage, 0f, 1f)), 1), true); + PotentialEnergyDamage = 0; + } + + oldVelocity = npc.velocity.Length(); + npc.Center += ForcedVel; + ForcedVel *= 0.995f; + } + else + { + float newVerticalVelocity = npc.velocity.Y; + float oldVerticalVelocity = OldVelocity.Y; + float olderVerticalVelocity = OlderVelocity.Y; + + //If the thing flies back up, cancel the fall dmg + if (newVerticalVelocity < 0 && oldVerticalVelocity >= 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 && olderVerticalVelocity > 0 && oldVerticalVelocity < olderVerticalVelocity) + PotentialEnergyDamage = 0; + + //If the npc hit a tile/Came to a stop after falling + if (newVerticalVelocity == 0 && oldVerticalVelocity > 0) //Collision.SolidCollision(npc.Center, npc.width, npc.height)) + { + //I don't think a tile check below the npc is necessary but if we find weird edge cases ill add it + npc.StrikeNPC(npc.CalculateHitInfo((int)(PotentialEnergyDamage * Math.Clamp(olderVerticalVelocity / terminalVelocityForFullFallDamage, 0f, 1f)), 1), true); + PotentialEnergyDamage = 0; + } + + OlderVelocity = OldVelocity; + OldVelocity = npc.velocity; + } } } } diff --git a/Projectiles/Melee/GrandDadGhost.png b/Projectiles/Melee/GrandDadGhost.png new file mode 100644 index 0000000000..f23f0dfbb5 Binary files /dev/null and b/Projectiles/Melee/GrandDadGhost.png differ diff --git a/Projectiles/Melee/GrandDadHoldout.cs b/Projectiles/Melee/GrandDadHoldout.cs new file mode 100644 index 0000000000..1865fe096c --- /dev/null +++ b/Projectiles/Melee/GrandDadHoldout.cs @@ -0,0 +1,258 @@ +using System; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs.Abyss; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.PrimordialWyrm; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.CodeAnalysis.CSharp.Formatting; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Renderers; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class GrandDadHoldout : BaseCustomUseStyleProjectile, ILocalizedModType + { + public override int AssignedItemID => ModContent.ItemType(); + + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + + public override float HitboxOutset => 125; + + public override Vector2 HitboxSize => new Vector2(170, 170); + public override float HitboxRotationOffset => MathHelper.ToRadians(-45); + + public override Vector2 SpriteOrigin => new(0, 124); + public Vector2 mousePos; + public Vector2 aimVel; + public bool doSwing = true; + public bool postSwing = false; + public float fadeIn = 0; + public int useAnim; + public int swingCount; + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 20; + } + public override void OnSpawn(IEntitySource source) + { + Projectile.scale = 1f; + Projectile.ai[1] = 1; + base.OnSpawn(source); + mousePos = Owner.Calamity().mouseWorld; + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + useAnim = Owner.itemAnimationMax; + + if (mousePos.X < Owner.Center.X) Owner.direction = -1; + else Owner.direction = 1; + + FlipAsSword = Owner.direction == -1 ? true : false; + } + + public override void UseStyle() + { + DrawUnconditionally = false; + + if (CanHit || postSwing) + mousePos = Owner.Center - aimVel; + else + { + mousePos = Owner.Calamity().mouseWorld; + } + + if (!doSwing) + { + Projectile.numHits = 0; + mousePos = Owner.Calamity().mouseWorld; + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + CanHit = false; + if (mousePos.X < Owner.Center.X) Owner.direction = -1; + else Owner.direction = 1; + FlipAsSword = Owner.direction == -1 ? true : false; + + doSwing = true; + swingCount++; + } + else + { + if (!CanHit && !postSwing) + { + if (mousePos.X < Owner.Center.X) Owner.direction = -1; + else Owner.direction = 1; + } + else + { + if ((Owner.Center - aimVel).X < Owner.Center.X) Owner.direction = -1; + else Owner.direction = 1; + } + + + Projectile.rotation = Projectile.rotation.AngleLerp(Owner.AngleTo(mousePos) + MathHelper.ToRadians(65f), 0.1f); + + if (AnimationProgress < (useAnim / 3)) + { + aimVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitX) * 65; + CanHit = false; + postSwing = false; + if (AnimationProgress == 0) + { + doSwing = false; + Projectile.ai[1] = -Projectile.ai[1]; + } + RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(120f * Projectile.ai[1] * Owner.direction), 0.2f); + } + else + { + float time = (AnimationProgress) - (useAnim / 3); + float timeMax = useAnim - (useAnim / 3); + + if (time == (int)(timeMax * 0.4f)) + { + SoundStyle fire = new("CalamityMod/Sounds/Item/HeavySwing"); + SoundEngine.PlaySound(fire with { Volume = 0.8f, Pitch = 0.3f }, Projectile.Center); + } + if ( time > (int)(timeMax * 0.4f) && time < (int)(timeMax * 0.7f)) + { + CanHit = true; + + for (int i = 0; i < 3; i++) + { + Vector2 particleVel = new Vector2(0, 10 * -Projectile.ai[1] * Owner.direction).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)); + Vector2 particlePos = Owner.Center + (new Vector2(Main.rand.Next(30, 170), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))); + GeneralParticleHandler.SpawnParticle(new LineParticle(particlePos, -particleVel.RotatedByRandom(0.2f) * 2, false, 19, Main.rand.NextFloat(0.5f, 1f), Main.rand.NextBool(4) ? Color.DodgerBlue : Color.Blue)); + GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(particlePos, -particleVel.RotatedByRandom(0.2f) * 2, Main.rand.NextBool(4) ? Color.Black : Color.DarkBlue, 23, Main.rand.NextFloat(0.5f, 1f), 0.65f)); + } + } + else + CanHit = false; + + RotationOffset = MathHelper.Lerp(RotationOffset, MathHelper.ToRadians(MathHelper.Lerp(150f * Projectile.ai[1] * Owner.direction, 120f * -Projectile.ai[1] * Owner.direction, CalamityUtils.ExpInOutEasing(time / timeMax, 1))), + 0.2f); + + if (time >= timeMax) + doSwing = false; + if (time < (int)(timeMax * 0.7f)) + postSwing = true; + + if (CanHit) + { + for (int i = 0; i < 3; i++) + { + GeneralParticleHandler.SpawnParticle(new GlowOrbParticle(Owner.Center + (new Vector2(170, 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)).RotatedByRandom(0.3f)), Vector2.Zero, false, 24, Main.rand.NextFloat(0.5f, 1f), Main.rand.NextBool(4) ? Color.Gold : Color.Goldenrod)); + } + } + } + } + + ArmRotationOffset = MathHelper.ToRadians(-140f); + ArmRotationOffsetBack = MathHelper.ToRadians(-140f); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + SoundStyle fire = new("CalamityMod/Sounds/NPCHit/ThanatosHitOpen1"); + SoundEngine.PlaySound(fire with { Volume = 0.75f, Pitch = -0.1f }, Projectile.Center); + SoundStyle fire2 = new("CalamityMod/Sounds/Item/FinalDawnSlash"); + SoundEngine.PlaySound(fire2 with { Volume = 0.65f, Pitch = Main.rand.NextFloat(-0.2f, -0.3f) }, Projectile.Center); + if (Main.zenithWorld && Projectile.numHits == 0) + { + SoundStyle fire3 = new("CalamityMod/Sounds/Item/GFBScreams/Scream", 5); + SoundEngine.PlaySound(fire3 with { Volume = 0.8f }, Projectile.Center); + } + if (Projectile.numHits == 0) + Owner.Calamity().GeneralScreenShakePower = 6.5f; + + bool isAPillar = target.type == NPCID.LunarTowerSolar || target.type == NPCID.LunarTowerVortex || target.type == NPCID.LunarTowerNebula || target.type == NPCID.LunarTowerStardust; + if (!isAPillar && !target.boss && target.IsAnEnemy(true, true) && !CalamityPlayer.areThereAnyDamnBosses && target.CanBeChasedBy(Projectile, false) || Main.zenithWorld || target.type == ModContent.NPCType()) + { + if (target.type == ModContent.NPCType()) + { + CombatText.NewText(target.Hitbox, Color.Aqua, "boop!"); + SoundStyle boop = new("CalamityMod/Sounds/Item/SnootBooped"); + SoundEngine.PlaySound(boop with {Pitch = Main.rand.NextFloat(-0.15f, 0.15f) }, Projectile.Center); + } + + bool rightClicked = Owner.Calamity().mouseRight; + + // Make all hit enemies able to hit tiles, so you can dunk them + target.noTileCollide = false; + + // Launch the suckers + Vector2 launchVel = (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * (Main.zenithWorld ? -50 : -30) * (rightClicked ? 2 : 1); + target.velocity = launchVel; + + // If enemies are sitting on platforms, force them down so they can get dunked on the floor + if (launchVel.Y > 0) + target.Center += new Vector2(3, 0); + + // Remove knockback resist, just like it used to + target.knockBackResist = 1; + + // Apply tile collison damage (is bonus on GFB and even further is both final bosses are gone) + target.FallingNPC().ApplyFallDamage(target, Projectile.damage * (Main.zenithWorld ? (DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs ? 1000 : 25) : 3) * (rightClicked ? 2 : 1), launchVel * 0.5f, 5f, true); + } + Particle spark = new VoidSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35, false, 13, 0.5f, Color.DodgerBlue); + GeneralParticleHandler.SpawnParticle(spark); + for (int i = 0; i < MathHelper.Clamp(10 - Projectile.numHits * 2, 2, 10); i++) + { + Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), true, 55, Main.rand.NextFloat(0.4f, 1.5f), Main.rand.NextBool(4) ? Color.DodgerBlue : Color.Blue); + GeneralParticleHandler.SpawnParticle(spark2); + if (Main.rand.NextBool(5)) + { + Particle spark3 = new AltSparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -35).RotatedByRandom(0.7) * Main.rand.NextFloat(0.2f, 1f), true, 55, Main.rand.NextFloat(0.4f, 1.5f), Color.Black); + GeneralParticleHandler.SpawnParticle(spark3); + } + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Owner.Calamity().mouseRight) + modifiers.SourceDamage *= 0.001f; + } + public override bool PreDraw(ref Color lightColor) + { + // Only draw the projectile if the projectile's owner is currently using the item this projectile is attached to. + if ((useAnim > 0 || DrawUnconditionally) && Owner.ItemAnimationActive) + { + Asset tex = ModContent.Request(Texture); + + float r = FlipAsSword ? MathHelper.ToRadians(90) : 0f; + + if (CanHit) + fadeIn = MathHelper.Lerp(fadeIn, 1, 0.06f); + else + fadeIn = MathHelper.Lerp(fadeIn, 0, 0.06f); + + if (CanHit) + { + for (int i = 0; i < 5; i++) + { + Color auraColor = Color.Lerp(Color.DarkGoldenrod, Color.Gold, Utils.GetLerpValue(0, 5, i)) * 0.5f * fadeIn; + Texture2D centerTexture = ModContent.Request("CalamityMod/Projectiles/Melee/GrandDadGhost").Value; + Vector2 rotationalDrawOffset = (MathHelper.TwoPi * i / 7f + Main.GlobalTimeWrappedHourly * 17f).ToRotationVector2(); + rotationalDrawOffset *= MathHelper.Lerp(3f, 5.25f, (float)Math.Cos(Main.GlobalTimeWrappedHourly * 4f) * 0.5f + 1.5f); + Main.EntitySpriteDraw(centerTexture, Projectile.Center - Main.screenPosition + rotationalDrawOffset + new Vector2(0, Owner.gfxOffY), centerTexture.Frame(1, FrameCount, 0, Frame), auraColor, Projectile.rotation + RotationOffset + r, FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None)); + } + } + + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + new Vector2(0, Owner.gfxOffY), tex.Frame(1, FrameCount, 0, Frame), lightColor, Projectile.rotation + RotationOffset + r, FlipAsSword ? new Vector2(tex.Width() - SpriteOrigin.X, SpriteOrigin.Y) : SpriteOrigin, Projectile.scale, spriteEffects != SpriteEffects.None ? spriteEffects : (FlipAsSword ? SpriteEffects.FlipHorizontally : SpriteEffects.None)); + + } + return false; + } + public override void ResetStyle() + { + } + } +} diff --git a/Projectiles/Melee/GrandDadHoldout.png b/Projectiles/Melee/GrandDadHoldout.png new file mode 100644 index 0000000000..09d8d4c91b Binary files /dev/null and b/Projectiles/Melee/GrandDadHoldout.png differ diff --git a/Projectiles/Melee/Spears/RedtideSpearProjectile.cs b/Projectiles/Melee/Spears/RedtideSpearProjectile.cs index bd510bc616..ad465235a7 100644 --- a/Projectiles/Melee/Spears/RedtideSpearProjectile.cs +++ b/Projectiles/Melee/Spears/RedtideSpearProjectile.cs @@ -302,7 +302,7 @@ namespace CalamityMod.Projectiles.Melee.Spears if (CurrentAttackState == AttackState.UpwardsThrust) { target.velocity.Y -= 12 * (float)Math.Sqrt(target.knockBackResist); - target.FallingNPC().ApplyFallDamage(target, 50, 5f); + target.FallingNPC().ApplyFallDamage(target, 50, Vector2.Zero, 5f); } target.AddBuff(BuffID.Poisoned, 180); diff --git a/Sounds/Item/GFBScreams/Scream1.ogg b/Sounds/Item/GFBScreams/Scream1.ogg new file mode 100644 index 0000000000..4c6e6ccc85 Binary files /dev/null and b/Sounds/Item/GFBScreams/Scream1.ogg differ diff --git a/Sounds/Item/GFBScreams/Scream2.ogg b/Sounds/Item/GFBScreams/Scream2.ogg new file mode 100644 index 0000000000..759b7369aa Binary files /dev/null and b/Sounds/Item/GFBScreams/Scream2.ogg differ diff --git a/Sounds/Item/GFBScreams/Scream3.ogg b/Sounds/Item/GFBScreams/Scream3.ogg new file mode 100644 index 0000000000..dd4ae6dcda Binary files /dev/null and b/Sounds/Item/GFBScreams/Scream3.ogg differ diff --git a/Sounds/Item/GFBScreams/Scream4.ogg b/Sounds/Item/GFBScreams/Scream4.ogg new file mode 100644 index 0000000000..50db199b73 Binary files /dev/null and b/Sounds/Item/GFBScreams/Scream4.ogg differ diff --git a/Sounds/Item/GFBScreams/Scream5.ogg b/Sounds/Item/GFBScreams/Scream5.ogg new file mode 100644 index 0000000000..a1fdeae4b1 Binary files /dev/null and b/Sounds/Item/GFBScreams/Scream5.ogg differ diff --git a/Sounds/Item/HeavySwing.ogg b/Sounds/Item/HeavySwing.ogg new file mode 100644 index 0000000000..4cf73a1e28 Binary files /dev/null and b/Sounds/Item/HeavySwing.ogg differ diff --git a/Sounds/Item/SnootBooped.ogg b/Sounds/Item/SnootBooped.ogg new file mode 100644 index 0000000000..f97b59e4d4 Binary files /dev/null and b/Sounds/Item/SnootBooped.ogg differ