diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 3020c9db04..6c3c2ae053 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -114,7 +114,7 @@ namespace CalamityMod.CalPlayer Texture2D texture = ModContent.GetTexture("CalamityMod/ExtraTextures/IceShield"); int drawX = (int)(drawInfo.position.X + drawPlayer.width / 2f - Main.screenPosition.X); int drawY = (int)(drawInfo.position.Y + drawPlayer.height / 2f - Main.screenPosition.Y); - DrawData data = new DrawData(texture, new Vector2(drawX, drawY), null, Color.Cyan, 0f, texture.Size() * 0.5f, 1f, SpriteEffects.None, 0); + DrawData data = new DrawData(texture, new Vector2(drawX, drawY), null, Color.White, 0f, texture.Size() * 0.5f, 1f, SpriteEffects.None, 0); Main.playerDrawData.Add(data); } if (modPlayer.amidiasBlessing) diff --git a/DataStructures/Attunement.cs b/DataStructures/Attunement.cs index efa0e8d0bc..ddf7c43e3c 100644 --- a/DataStructures/Attunement.cs +++ b/DataStructures/Attunement.cs @@ -541,7 +541,7 @@ namespace CalamityMod.DataStructures if (UseTimer % 30 == 29 && Main.rand.Next(2) == 0) { Main.PlaySound(SoundID.Item78); - Projectile beamSword = Projectile.NewProjectileDirect(player.Center, player.DirectionTo(Main.MouseWorld) * 15f, ProjectileType(), (int)(OmegaBiomeBlade.WhirlwindAttunement_PassiveBaseDamage * player.MeleeDamage()), 10f, player.whoAmI, 1f); + Projectile beamSword = Projectile.NewProjectileDirect(player.Center, player.SafeDirectionTo(Main.MouseWorld, Vector2.One) * 15f, ProjectileType(), (int)(OmegaBiomeBlade.WhirlwindAttunement_PassiveBaseDamage * player.MeleeDamage()), 10f, player.whoAmI, 1f); beamSword.timeLeft = 50; UseTimer++; } diff --git a/Items/VanillaArmorChanges/CobaltArmorSetChange.cs b/Items/VanillaArmorChanges/CobaltArmorSetChange.cs index 89585ccf4d..a61ef4a13c 100644 --- a/Items/VanillaArmorChanges/CobaltArmorSetChange.cs +++ b/Items/VanillaArmorChanges/CobaltArmorSetChange.cs @@ -16,9 +16,9 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Cobalt"; - public const int SpeedBoostSetBonusPercentage = 15; + public const int SpeedBoostSetBonusPercentage = 10; public const int MaxManaBoost = 20; - public const int MovementSpeedBoostPercentageMax = 15; + public const int MovementSpeedBoostPercentageMax = 10; public const int MovementSpeedBoostMphThreshold = 60; public override void ApplyHeadPieceEffect(Player player) diff --git a/Items/Weapons/Magic/ClothiersWrath.cs b/Items/Weapons/Magic/ClothiersWrath.cs index 7914e3b0a6..045c22cf39 100644 --- a/Items/Weapons/Magic/ClothiersWrath.cs +++ b/Items/Weapons/Magic/ClothiersWrath.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 19; + item.damage = 38; item.magic = true; item.mana = 15; item.width = 28; @@ -25,8 +25,8 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 3f; - item.value = CalamityGlobalItem.Rarity3BuyPrice; - item.rare = ItemRarityID.Orange; + item.value = CalamityGlobalItem.Rarity4BuyPrice; + item.rare = ItemRarityID.LightRed; item.UseSound = SoundID.Item8; item.autoReuse = true; item.shoot = ProjectileID.ClothiersCurse; diff --git a/Items/Weapons/Melee/ArkoftheCosmos.cs b/Items/Weapons/Melee/ArkoftheCosmos.cs index 98ccf263ce..e10e244f67 100644 --- a/Items/Weapons/Melee/ArkoftheCosmos.cs +++ b/Items/Weapons/Melee/ArkoftheCosmos.cs @@ -23,15 +23,21 @@ namespace CalamityMod.Items.Weapons.Melee public override bool CloneNewInstances => true; public static float NeedleDamageMultiplier = 0.5f; + public static float MaxThrowReach = 620; public static float snapDamageMultiplier = 1.3f; //Extra damage from making the scissors snap + public static float chargeDamageMultiplier = 1.6f; //Extra damage from charge public static float chainDamageMultiplier = 0.1f; - public static int DashIframes = 18; + public static int DashIframes = 10; public static float SlashBoltsDamageMultiplier = 0.2f; public static float SnapBoltsDamageMultiplier = 0.1f; - public static float SwirlBoltAmount = 7f; + public static float blastDamageMultiplier = 0.5f; //Damage multiplier applied ontop of the charge damage multiplier mutliplied by the amount of charges consumed. So if you consume 5 charges, the blast will get multiplied by 5 times the damage multiplier + public static float blastFalloffSpeed = 0.1f; //How much the blast damage falls off as you hit more and more targets + public static float blastFalloffStrenght = 0.75f; //Value between 0 and 1 that determines how much falloff increases affect the damage : Closer to 0 = damage falls off less intensely, closer to 1 : damage falls off way harder + + public static float SwirlBoltAmount = 7f; //The amount of cosmic bolts produced during hte swirl attack public static float SwirlBoltDamageMultiplier = 0.8f; //This is the damage multiplier for ALL THE BOLTS: Aka, said damage multiplier is divided by the amount of bolts in a swirl and the full damage multiplier is gotten if you hit all the bolts const string ComboTooltip = "Performs a combo of swings, alternating between narrow and wide swings and throwing the blade out every 5 swings\n" + @@ -73,7 +79,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = item.height = 136; - item.damage = 1705; + item.damage = 2022; item.melee = true; item.noMelee = true; item.noUseGraphic = true; @@ -118,7 +124,7 @@ namespace CalamityMod.Items.Weapons.Melee if (Charge > 0 && player.controlUp) { float angle = new Vector2(speedX, speedY).ToRotation(); - Projectile.NewProjectile(player.Center + angle.ToRotationVector2() * 90f, new Vector2(speedX, speedY), ProjectileType(), (int)(damage * Charge * 1.8f), 0, player.whoAmI, Charge); + Projectile.NewProjectile(player.Center + angle.ToRotationVector2() * 90f, new Vector2(speedX, speedY), ProjectileType(), (int)(damage * Charge * chargeDamageMultiplier * blastDamageMultiplier), 0, player.whoAmI, Charge); if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3) Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3; @@ -144,7 +150,7 @@ namespace CalamityMod.Items.Weapons.Melee if (scissorState != 2) { Vector2 throwVector = new Vector2(speedX, speedY); - Projectile.NewProjectile(player.Center + Vector2.Normalize(throwVector) * 20, new Vector2(speedX, speedY) * 1.4f, ProjectileType(), (int)(damage * NeedleDamageMultiplier), knockBack, player.whoAmI); + Projectile.NewProjectile(player.Center + Utils.SafeNormalize(throwVector, Vector2.Zero) * 20, new Vector2(speedX, speedY) * 1.4f, ProjectileType(), (int)(damage * NeedleDamageMultiplier), knockBack, player.whoAmI); } Combo += 1; diff --git a/Items/Weapons/Melee/ArkoftheElements.cs b/Items/Weapons/Melee/ArkoftheElements.cs index 1f73eedd74..bd657ec4ea 100644 --- a/Items/Weapons/Melee/ArkoftheElements.cs +++ b/Items/Weapons/Melee/ArkoftheElements.cs @@ -25,6 +25,11 @@ namespace CalamityMod.Items.Weapons.Melee public static float snapDamageMultiplier = 1.3f; //Extra damage from making the scissors snap public static float chargeDamageMultiplier = 1.6f; //Extra damage from charge + public static float blastDamageMultiplier = 0.5f; //Damage multiplier applied ontop of the charge damage multiplier mutliplied by the amount of charges consumed. So if you consume 5 charges, the blast will get multiplied by 5 times the damage multiplier + public static float blastFalloffSpeed = 0.1f; //How much the blast damage falls off as you hit more and more targets + public static float blastFalloffStrenght = 0.75f; //Value between 0 and 1 that determines how much falloff increases affect the damage : Closer to 0 = damage falls off less intensely, closer to 1 : damage falls off way harder + + const string ComboTooltip = "Performs a combo of swings, throwing the blade out every 5 swings. Releasing the mouse while the blade is out will throw the second half towards it, making the scissors snap\n" + "Snapping the scissors together increase their damage and empower your next two swings"; @@ -107,7 +112,7 @@ namespace CalamityMod.Items.Weapons.Melee if (Charge > 0 && player.controlUp) { float angle = new Vector2(speedX, speedY).ToRotation(); - Projectile.NewProjectile(player.Center + angle.ToRotationVector2() * 90f, new Vector2(speedX, speedY), ProjectileType(), (int)(damage * Charge * 1.8f), 0, player.whoAmI); + Projectile.NewProjectile(player.Center + angle.ToRotationVector2() * 90f, new Vector2(speedX, speedY), ProjectileType(), (int)(damage * Charge * chargeDamageMultiplier * blastDamageMultiplier), 0, player.whoAmI); if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3) Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3; @@ -139,10 +144,10 @@ namespace CalamityMod.Items.Weapons.Melee { Vector2 throwVector = new Vector2(speedX, speedY); float empoweredNeedles = Charge > 0 ? 1f : 0f; - Projectile.NewProjectile(player.Center + Vector2.Normalize(throwVector) * 20, new Vector2(speedX, speedY) * 2.8f, ProjectileType(), (int)(damage * 0.5f), knockBack, player.whoAmI, empoweredNeedles); + Projectile.NewProjectile(player.Center + Utils.SafeNormalize(throwVector, Vector2.Zero) * 20, new Vector2(speedX, speedY) * 2.8f, ProjectileType(), (int)(damage * 0.5f), knockBack, player.whoAmI, empoweredNeedles); - Vector2 Shift = Vector2.Normalize(new Vector2(speedX, speedY).RotatedBy(MathHelper.PiOver2)) * 20; + Vector2 Shift = Utils.SafeNormalize(new Vector2(speedX, speedY).RotatedBy(MathHelper.PiOver2), Vector2.Zero) * 20; Projectile.NewProjectile(player.Center + Shift, throwVector.RotatedBy(MathHelper.PiOver4 * 0.3f), ProjectileType(), (int)(damage * 0.2f), knockBack, player.whoAmI); Projectile.NewProjectile(player.Center + Shift * 1.2f, throwVector.RotatedBy(MathHelper.PiOver4 * 0.4f) * 0.8f, ProjectileType(), (int)(damage * 0.2f), knockBack, player.whoAmI); @@ -201,13 +206,17 @@ namespace CalamityMod.Items.Weapons.Melee public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) { + float extraScale = 0.3f; Texture2D frontTexture = GetTexture("CalamityMod/Items/Weapons/Melee/ArkoftheElements"); Texture2D backTexture = GetTexture("CalamityMod/Items/Weapons/Melee/ArkoftheElementsBack"); + float tweakedScale = scale * (1 + extraScale); //Make the scale bigger to avoid crunching of the item + Vector2 offset = (frontTexture.Size() * extraScale / 2f) * scale; + float backLayerOpacity = (Charge > 0) ? 1f : (float)Math.Sin(Main.GlobalTime * 0.9f) * 0.2f + 0.3f; - spriteBatch.Draw(backTexture, position, null, drawColor * backLayerOpacity, 0f, origin, scale, SpriteEffects.None, 0f); //Make the back scissor slightly transparent if the ark isnt charged - spriteBatch.Draw(frontTexture, position, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(backTexture, position - offset, null, drawColor * backLayerOpacity, 0f, origin, tweakedScale, SpriteEffects.None, 0f); //Make the back scissor slightly transparent if the ark isnt charged + spriteBatch.Draw(frontTexture, position - offset, null, drawColor, 0f, origin, tweakedScale, SpriteEffects.None, 0f); return false; } diff --git a/Items/Weapons/Melee/TrueArkoftheAncients.cs b/Items/Weapons/Melee/TrueArkoftheAncients.cs index c44f525ffb..425a48d2c7 100644 --- a/Items/Weapons/Melee/TrueArkoftheAncients.cs +++ b/Items/Weapons/Melee/TrueArkoftheAncients.cs @@ -22,6 +22,11 @@ namespace CalamityMod.Items.Weapons.Melee public static float beamDamageMultiplier = 0.8f; //Damage multiplier for the charged shots (remember it applies ontop of the charge damage multiplied public static float glassStarDamageMultiplier = 0.2f; //Damage multiplier for the charged shots (remember it applies ontop of the charge damage multiplied + public static float blastDamageMultiplier = 0.5f; //Damage multiplier applied ontop of the charge damage multiplier mutliplied by the amount of charges consumed. So if you consume 5 charges, the blast will get multiplied by 5 times the damage multiplier + public static float blastFalloffSpeed = 0.1f; //How much the blast damage falls off as you hit more and more targets + public static float blastFalloffStrenght = 0.75f; //Value between 0 and 1 that determines how much falloff increases affect the damage : Closer to 0 = damage falls off less intensely, closer to 1 : damage falls off way harder + + public override bool CloneNewInstances => true; const string ParryTooltip = "Using RMB will extend the Ark out in front of you. Hitting an enemy with it will parry them, granting you a small window of invulnerability\n" + @@ -80,8 +85,9 @@ namespace CalamityMod.Items.Weapons.Melee { if (Charge > 0 && player.controlUp) { - float angle = new Vector2(speedX, speedY).ToRotation(); - Projectile.NewProjectile(player.Center + angle.ToRotationVector2() * 90f, Vector2.Zero, ProjectileType(), (int)(damage * Charge * chargeDamageMultiplier * 0.8f), 0, player.whoAmI, angle, 600); + float angle = player.SafeDirectionTo(Main.MouseWorld, Vector2.UnitY).ToRotation(); + Vector2 laserVector = player.SafeDirectionTo(Main.MouseWorld, Vector2.UnitY) * 600; + Projectile.NewProjectile(player.Center + angle.ToRotationVector2() * 90f, laserVector, ProjectileType(), (int)(damage * Charge * chargeDamageMultiplier * blastDamageMultiplier), 0, player.whoAmI); if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3) Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3; @@ -109,9 +115,9 @@ namespace CalamityMod.Items.Weapons.Melee { //Only shoot the center star if theres no charge if (Charge == 0) - Projectile.NewProjectile(player.Center + Vector2.Normalize(new Vector2(speedX, speedY)) * 20, new Vector2(speedX, speedY), ProjectileType(), (int)(damage * glassStarDamageMultiplier), knockBack, player.whoAmI); + Projectile.NewProjectile(player.Center + Utils.SafeNormalize(new Vector2(speedX, speedY), Vector2.Zero) * 20, new Vector2(speedX, speedY), ProjectileType(), (int)(damage * glassStarDamageMultiplier), knockBack, player.whoAmI); - Vector2 Shift = Vector2.Normalize(new Vector2(speedX, speedY).RotatedBy(MathHelper.PiOver2)) * 30; + Vector2 Shift = Utils.SafeNormalize(new Vector2(speedX, speedY).RotatedBy(MathHelper.PiOver2), Vector2.Zero) * 30; Projectile.NewProjectile(player.Center + Shift, new Vector2(speedX, speedY).RotatedBy(MathHelper.PiOver4 * 0.3f) , ProjectileType(), (int)(damage * glassStarDamageMultiplier), knockBack, player.whoAmI, Charge > 0 ? 1 : 0); Projectile.NewProjectile(player.Center - Shift, new Vector2(speedX, speedY).RotatedBy(-MathHelper.PiOver4 * 0.3f), ProjectileType(), (int)(damage * glassStarDamageMultiplier), knockBack, player.whoAmI, Charge > 0 ? 1 : 0); diff --git a/Projectiles/Magic/NightsRayBeam.cs b/Projectiles/Magic/NightsRayBeam.cs index b9ca198c46..12e112e3b2 100644 --- a/Projectiles/Magic/NightsRayBeam.cs +++ b/Projectiles/Magic/NightsRayBeam.cs @@ -7,10 +7,10 @@ namespace CalamityMod.Projectiles.Magic { public ref float Time => ref projectile.ai[0]; public bool HasFiredSideBeams - { + { get => projectile.ai[1] == 1f; set => projectile.ai[1] = value.ToInt(); - } + } public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() { @@ -23,30 +23,14 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; - projectile.ignoreWater = true; - projectile.penetrate = 10; + projectile.ignoreWater = true; + projectile.penetrate = 10; projectile.extraUpdates = 100; projectile.timeLeft = 150; } public override void AI() { - if (!HasFiredSideBeams && projectile.owner == Main.myPlayer) - { - NPC potentialTarget = projectile.Center.ClosestNPCAt(5480f, false); - if (potentialTarget != null) - { - Vector2 baseSpawnPositionOffset = Main.rand.NextVector2CircularEdge(40f, 40f); - for (int i = 0; i < 4; i++) - { - Vector2 spawnPosition = potentialTarget.Center + baseSpawnPositionOffset.RotatedBy(MathHelper.TwoPi * i / 4f); - Projectile.NewProjectile(spawnPosition, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.8), projectile.knockBack, projectile.owner); - } - HasFiredSideBeams = true; - projectile.netUpdate = true; - } - } - Time++; if (Time >= 10f) { @@ -57,8 +41,23 @@ namespace CalamityMod.Projectiles.Magic corruptMagic.color = Color.Lerp(Color.Fuchsia, Color.Magenta, Main.rand.NextFloat(0.6f)); corruptMagic.scale = Main.rand.NextFloat(0.96f, 1.04f); corruptMagic.noGravity = true; - corruptMagic.velocity *= 0.1f; - } + corruptMagic.velocity *= 0.1f; + } + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (!HasFiredSideBeams && projectile.owner == Main.myPlayer) + { + Vector2 baseSpawnPositionOffset = Main.rand.NextVector2CircularEdge(40f, 40f); + for (int i = 0; i < 4; i++) + { + Vector2 spawnPosition = target.Center + baseSpawnPositionOffset.RotatedBy(MathHelper.TwoPi * i / 4f); + Projectile.NewProjectile(spawnPosition, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.8), projectile.knockBack, projectile.owner); + } + HasFiredSideBeams = true; + projectile.netUpdate = true; } } } diff --git a/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs index 6759a5059c..11e6f4c878 100644 --- a/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheAncients_ParryHoldout.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee public override string Texture => "CalamityMod/Items/Weapons/Melee/ArkoftheAncients"; private bool initialized = false; - const float MaxTime = 160; + const float MaxTime = 340; static float ParryTime = 15; public Vector2 DistanceFromPlayer => projectile.velocity * 10 * (1f + ((float)Math.Sin(Timer / ParryTime * MathHelper.Pi) * 0.8f)); public float Timer => MaxTime - projectile.timeLeft; @@ -96,7 +96,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = (int)MaxTime; Main.PlaySound(SoundID.DD2_SkyDragonsFuryShot, projectile.Center); - projectile.velocity = Owner.DirectionTo(Owner.Calamity().mouseWorld); + projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); projectile.velocity.Normalize(); projectile.rotation = projectile.velocity.ToRotation(); @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Melee //Manage position and rotation projectile.Center = Owner.Center + DistanceFromPlayer ; - projectile.scale = 1.4f + ((float)Math.Sin(Timer / MaxTime * MathHelper.Pi) * 0.6f); //SWAGGER + projectile.scale = 1.4f + ((float)Math.Sin(Timer / 160f * MathHelper.Pi) * 0.6f); //SWAGGER if (Timer > ParryTime) return; @@ -136,7 +136,7 @@ namespace CalamityMod.Projectiles.Melee //Bounce off the player if they are in the air if (Owner.velocity.Y != 0) - Owner.velocity += Vector2.Normalize(Owner.Center - proj.Center) * 2; + Owner.velocity += Utils.SafeNormalize(Owner.Center - proj.Center, Vector2.Zero) * 2; break; } } diff --git a/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs b/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs index 3dd27c02c5..c14c93dc76 100644 --- a/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs +++ b/Projectiles/Melee/ArkOfTheAncients_SwungBlade.cs @@ -99,7 +99,7 @@ namespace CalamityMod.Projectiles.Melee if (Owner.whoAmI == Main.myPlayer && SwingRatio() > 0.5f && HasFired == 0f && Charge > 0) { - Projectile.NewProjectile(Owner.Center + direction * 30f, projectile.velocity * 1f, ProjectileType(), (int)(projectile.damage * ArkoftheAncients.beamDamageMultiplier), 2f, Owner.whoAmI) ; + Projectile.NewProjectile(Owner.Center + direction * 30f, projectile.velocity * 1.25f, ProjectileType(), (int)(projectile.damage * ArkoftheAncients.beamDamageMultiplier), 2f, Owner.whoAmI) ; HasFired = 1f; } diff --git a/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs b/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs index 15af1381be..eb3f8e965c 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_BlastAttack.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Melee { public class ArkoftheCosmosBlast : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Melee/RendingScissorsRight"; + public override string Texture => "CalamityMod/Projectiles/Melee/RendingScissorsRight"; //Umm actually the rending scissors are for aote mr programmer what the hel.. it gets changed in predraw anywyas private bool initialized = false; public ref float Charge => ref projectile.ai[0]; @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Melee { projectile.ai[1] = value ? 1f : 0f; } - } + } const int maxStitches = 8; public int CurrentStitches => (int)Math.Ceiling((1 - (float)Math.Sqrt(1f - (float)Math.Pow(MathHelper.Clamp(StitchProgress * 3f, 0f, 1f), 2f))) * maxStitches); @@ -60,6 +60,8 @@ namespace CalamityMod.Projectiles.Melee public Vector2 scissorPosition => projectile.Center + ThrustDisplaceRatio() * projectile.velocity * 200f; + public ref float HitCounter => ref projectile.localAI[0]; + public Player Owner => Main.player[projectile.owner]; public Particle PolarStar; @@ -119,36 +121,7 @@ namespace CalamityMod.Projectiles.Melee //Manage position and rotation projectile.scale = 1.4f; - if (PolarStar == null) - { - PolarStar = new GenericSparkle(projectile.Center, Vector2.Zero, Color.White, Color.CornflowerBlue, projectile.scale * 2f, 2, 0.1f, 5f, true); - GeneralParticleHandler.SpawnParticle(PolarStar); - } - else if (HoldProgress <= 0.4f) - { - PolarStar.Time = 0; - PolarStar.Position = scissorPosition; - PolarStar.Scale = projectile.scale * 2f; - } - - //Update stitches - for (int i = 0; i < CurrentStitches; i++) - { - if (StitchRotations[i] == 0) - { - StitchRotations[i] = Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4) + MathHelper.PiOver2; - var sewSound = Main.PlaySound(i % 3 == 0 ? SoundID.Item63 : i % 3 == 1 ? SoundID.Item64 : SoundID.Item65, Owner.Center); - SafeVolumeChange(ref sewSound, 0.5f); - - float positionAlongLine = (ThrustDisplaceRatio() * 242f / (float)maxStitches * 0.5f) + MathHelper.Lerp(0f, ThrustDisplaceRatio() * 242f, i / (float)maxStitches); - Vector2 stitchCenter = projectile.Center + projectile.velocity * positionAlongLine; - - - Particle spark = new CritSpark(stitchCenter, Vector2.Zero, Color.White, Color.Cyan, 3f, 8, 0.1f, 3); - GeneralParticleHandler.SpawnParticle(spark); - } - StitchLifetimes[i]++; - } + HandleParticles(); //Spawn particles when the line appears if (HoldTimer == 1) @@ -196,7 +169,7 @@ namespace CalamityMod.Projectiles.Melee { Owner.Calamity().LungingDown = true; Owner.fallStart = (int)(Owner.position.Y / 16f); - Owner.velocity = Owner.DirectionTo(scissorPosition) * 60f; + Owner.velocity = Owner.SafeDirectionTo(scissorPosition, Vector2.Zero) * 60f; if (Owner.Distance(scissorPosition) < 60f) { @@ -218,6 +191,40 @@ namespace CalamityMod.Projectiles.Melee } } + public void HandleParticles() + { + if (PolarStar == null) + { + PolarStar = new GenericSparkle(projectile.Center, Vector2.Zero, Color.White, Color.CornflowerBlue, projectile.scale * 2f, 2, 0.1f, 5f, true); + GeneralParticleHandler.SpawnParticle(PolarStar); + } + else if (HoldProgress <= 0.4f) + { + PolarStar.Time = 0; + PolarStar.Position = scissorPosition; + PolarStar.Scale = projectile.scale * 2f; + } + + //Update stitches + for (int i = 0; i < CurrentStitches; i++) + { + if (StitchRotations[i] == 0) + { + StitchRotations[i] = Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4) + MathHelper.PiOver2; + var sewSound = Main.PlaySound(i % 3 == 0 ? SoundID.Item63 : i % 3 == 1 ? SoundID.Item64 : SoundID.Item65, Owner.Center); + SafeVolumeChange(ref sewSound, 0.5f); + + float positionAlongLine = (ThrustDisplaceRatio() * 242f / (float)maxStitches * 0.5f) + MathHelper.Lerp(0f, ThrustDisplaceRatio() * 242f, i / (float)maxStitches); + Vector2 stitchCenter = projectile.Center + projectile.velocity * positionAlongLine; + + + Particle spark = new CritSpark(stitchCenter, Vector2.Zero, Color.White, Color.Cyan, 3f, 8, 0.1f, 3); + GeneralParticleHandler.SpawnParticle(spark); + } + StitchLifetimes[i]++; + } + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { Color pulseColor = Main.rand.NextBool() ? (Main.rand.NextBool() ? Color.Orange : Color.Coral) : (Main.rand.NextBool() ? Color.OrangeRed : Color.Gold); @@ -232,6 +239,13 @@ namespace CalamityMod.Projectiles.Melee } } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + //Add some damage falloff + damage = (int)(damage * Math.Pow((1 - ArkoftheCosmos.blastFalloffStrenght), HitCounter * ArkoftheCosmos.blastFalloffSpeed)); + HitCounter++; + } + public override void Kill(int timeLeft) { if (Dashing) diff --git a/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs index 734d24d748..ffbf00b35f 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_ParryHoldout.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee public override string Texture => "CalamityMod/Projectiles/Melee/RendingScissorsRight"; private bool initialized = false; - const float MaxTime = 160; + const float MaxTime = 340; static float ParryTime = 15; public Vector2 DistanceFromPlayer => projectile.velocity * 10 + projectile.velocity * 10 * ThrustDisplaceRatio(); public float Timer => MaxTime - projectile.timeLeft; @@ -113,7 +113,7 @@ namespace CalamityMod.Projectiles.Melee var sound = Main.PlaySound(SoundID.Item84, projectile.Center); CalamityUtils.SafeVolumeChange(ref sound, 0.3f); - projectile.velocity = Owner.DirectionTo(Main.MouseWorld); + projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); projectile.velocity.Normalize(); projectile.rotation = projectile.velocity.ToRotation(); @@ -145,7 +145,7 @@ namespace CalamityMod.Projectiles.Melee { GeneralParryEffects(); if (Owner.velocity.Y != 0) - Owner.velocity += Vector2.Normalize(Owner.Center - proj.Center) * 2; + Owner.velocity += Utils.SafeNormalize(Owner.Center - proj.Center, Vector2.Zero) * 2; } //Reduce the projectile's damage by 300 for a second. diff --git a/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs b/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs index 806dadc080..39b21ac742 100644 --- a/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs +++ b/Projectiles/Melee/ArkOfTheCosmos_SwungBlade.cs @@ -65,7 +65,6 @@ namespace CalamityMod.Projectiles.Melee private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed && Owner.HeldItem.type == ItemType(); public bool Thrown => Combo == 2 || Combo == 3; public const float MaxThrowTime = 140; - public const float ThrowReachMax = 500; public float ThrowReach; public float ThrowTimer => MaxThrowTime - projectile.timeLeft; public float ThrowCompletion => ThrowTimer / MaxThrowTime; @@ -218,8 +217,8 @@ namespace CalamityMod.Projectiles.Melee projectile.Center = Vector2.Lerp(projectile.Center, Owner.Calamity().mouseWorld, 0.025f * ThrowRatio()); projectile.Center = projectile.Center.MoveTowards(Owner.Calamity().mouseWorld, 20f * ThrowRatio()); - if ((projectile.Center - Owner.Center).Length() > ThrowReachMax) - projectile.Center = Owner.Center + Owner.DirectionTo(projectile.Center) * ThrowReachMax; + if ((projectile.Center - Owner.Center).Length() > ArkoftheCosmos.MaxThrowReach) + projectile.Center = Owner.Center + Owner.DirectionTo(projectile.Center) * ArkoftheCosmos.MaxThrowReach; projectile.rotation -= MathHelper.PiOver4 * 0.3f; projectile.scale = 1f + ThrowScaleRatio() * 0.5f; @@ -328,7 +327,7 @@ namespace CalamityMod.Projectiles.Melee { float maxDistance = projectile.scale * 78f; Vector2 distance = Main.rand.NextVector2Circular(maxDistance, maxDistance); - Vector2 angularVelocity = Vector2.Normalize(distance.RotatedBy(MathHelper.PiOver2 * Owner.direction)) * 2 * (1f + distance.Length() / 15f); + Vector2 angularVelocity = Utils.SafeNormalize(distance.RotatedBy(MathHelper.PiOver2 * Owner.direction), Vector2.Zero) * 2 * (1f + distance.Length() / 15f); Particle glitter = new CritSpark(Owner.Center + distance, Owner.velocity + angularVelocity, Main.rand.Next(3) == 0 ? Color.Turquoise : Color.Coral, currentColor, 1f + 1 * (distance.Length() / maxDistance), 10, 0.05f, 3f); GeneralParticleHandler.SpawnParticle(glitter); } @@ -387,7 +386,7 @@ namespace CalamityMod.Projectiles.Melee { float maxDistance = projectile.scale * 78f; Vector2 distance = Main.rand.NextVector2Circular(maxDistance, maxDistance); - Vector2 angularVelocity = Vector2.Normalize(distance.RotatedBy(-MathHelper.PiOver2)) * 2 * (1f + distance.Length() / 15f); + Vector2 angularVelocity = Utils.SafeNormalize(distance.RotatedBy(-MathHelper.PiOver2), Vector2.Zero) * 2 * (1f + distance.Length() / 15f); Color glitterColor = Main.hslToRgb(Main.rand.NextFloat(), 1, 0.5f); Particle glitter = new CritSpark(projectile.Center + distance, Owner.velocity + angularVelocity, Color.White , glitterColor, 1f + 1 * (distance.Length() / maxDistance), 10, 0.05f, 3f); GeneralParticleHandler.SpawnParticle(glitter); @@ -456,7 +455,7 @@ namespace CalamityMod.Projectiles.Melee Main.PlaySound(SoundID.Item84, projectile.Center); - Vector2 sliceDirection = Vector2.Normalize(direction) * 40; + Vector2 sliceDirection = Utils.SafeNormalize(direction, Vector2.One) * 40; Particle SliceLine = new LineVFX(projectile.Center - sliceDirection, sliceDirection * 2f, 0.2f, Color.Orange * 0.7f, expansion : 250f) { Lifetime = 10 diff --git a/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs b/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs index 260715dcde..774bfe31c6 100644 --- a/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs +++ b/Projectiles/Melee/ArkOfTheElements_ParryHoldout.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee public override string Texture => "CalamityMod/Projectiles/Melee/RendingScissorsRight"; private bool initialized = false; - const float MaxTime = 160; + const float MaxTime = 340; static float ParryTime = 15; public Vector2 DistanceFromPlayer => projectile.velocity * 10 + projectile.velocity * 10 * ThrustDisplaceRatio(); public float Timer => MaxTime - projectile.timeLeft; @@ -113,7 +113,7 @@ namespace CalamityMod.Projectiles.Melee var sound = Main.PlaySound(SoundID.Item84, projectile.Center); CalamityUtils.SafeVolumeChange(ref sound, 0.3f); - projectile.velocity = Owner.DirectionTo(Main.MouseWorld); + projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); projectile.velocity.Normalize(); projectile.rotation = projectile.velocity.ToRotation(); @@ -145,7 +145,7 @@ namespace CalamityMod.Projectiles.Melee { GeneralParryEffects(); if (Owner.velocity.Y != 0) - Owner.velocity += Vector2.Normalize(Owner.Center - proj.Center) * 2; + Owner.velocity += Utils.SafeNormalize(Owner.Center - proj.Center, Vector2.Zero) * 2; } //Reduce the projectile's damage by 200 for a second. diff --git a/Projectiles/Melee/ArkOfTheElements_SnapBlast.cs b/Projectiles/Melee/ArkOfTheElements_SnapBlast.cs index 88b5d0ff7b..b685f898f6 100644 --- a/Projectiles/Melee/ArkOfTheElements_SnapBlast.cs +++ b/Projectiles/Melee/ArkOfTheElements_SnapBlast.cs @@ -44,6 +44,8 @@ namespace CalamityMod.Projectiles.Melee public int CurrentAnimation => (MaxTime - projectile.timeLeft) <= SnapTime ? 0 : (MaxTime - projectile.timeLeft) <= SnapTime + HoldTime ? 1 : 2; + public ref float HitCounter => ref projectile.ai[0]; + public Player Owner => Main.player[projectile.owner]; public override void SetStaticDefaults() @@ -165,6 +167,12 @@ namespace CalamityMod.Projectiles.Melee GeneralParticleHandler.SpawnParticle(energyLeak); } } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + //Add some damage falloff + damage = (int)(damage * Math.Pow((1 - ArkoftheElements.blastFalloffStrenght), HitCounter * ArkoftheElements.blastFalloffSpeed)); + HitCounter++; + } //Animation keys public CurveSegment anticipation = new CurveSegment(EasingType.SineBump, 0f, 0.2f, -0.1f); diff --git a/Projectiles/Melee/ArkoftheCosmos_Constellation.cs b/Projectiles/Melee/ArkoftheCosmos_Constellation.cs index a3f625ffa2..cd975416f0 100644 --- a/Projectiles/Melee/ArkoftheCosmos_Constellation.cs +++ b/Projectiles/Melee/ArkoftheCosmos_Constellation.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 AnchorStart => Owner.Center; Vector2 AnchorEnd => Owner.Calamity().mouseWorld; - public Vector2 SizeVector => Utils.SafeNormalize(AnchorEnd - AnchorStart, Vector2.Zero) * MathHelper.Clamp((AnchorEnd - AnchorStart).Length(), 0, ArkoftheCosmosSwungBlade.ThrowReachMax); + public Vector2 SizeVector => Utils.SafeNormalize(AnchorEnd - AnchorStart, Vector2.Zero) * MathHelper.Clamp((AnchorEnd - AnchorStart).Length(), 0, ArkoftheCosmos.MaxThrowReach); public override void SetStaticDefaults() { @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Melee constellationColorHue = (constellationColorHue + 0.16f) % 1; constellationColor = Main.hslToRgb(constellationColorHue, 1, 0.8f); - offset = Main.rand.NextFloat(-50f, 50f) * Vector2.Normalize(SizeVector.RotatedBy(MathHelper.PiOver2)); + offset = Main.rand.NextFloat(-50f, 50f) * Utils.SafeNormalize(SizeVector.RotatedBy(MathHelper.PiOver2), Vector2.Zero); Star = new GenericSparkle(AnchorStart + SizeVector * i + offset, Vector2.Zero, Color.White, constellationColor, Main.rand.NextFloat(1f, 1.5f), 20, 0f, 3f); BootlegSpawnParticle(Star); @@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Melee constellationColorHue = (constellationColorHue + 0.16f) % 1; constellationColor = Main.hslToRgb(constellationColorHue, 1, 0.8f); - offset = Main.rand.NextFloat(-50f, 50f) * Vector2.Normalize(SizeVector.RotatedBy(MathHelper.PiOver2)); + offset = Main.rand.NextFloat(-50f, 50f) * Utils.SafeNormalize(SizeVector.RotatedBy(MathHelper.PiOver2), Vector2.Zero); Star = new GenericSparkle(AnchorStart + SizeVector * i + offset, Vector2.Zero, Color.White, constellationColor, Main.rand.NextFloat(1f, 1.5f), 20, 0f, 3f); BootlegSpawnParticle(Star); diff --git a/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs b/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs index bebaf99992..203b2aaf60 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_AridGrandeur.cs @@ -122,7 +122,7 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(projectile.Center, new Vector3(1f, 0.56f, 0.56f) * ShredRatio); //Manage position and rotation - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); projectile.Center = Owner.Center + (direction * 60); diff --git a/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs b/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs index 7cd9462c7e..983d976b44 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_BitingEmbrace.cs @@ -133,7 +133,7 @@ namespace CalamityMod.Projectiles.Melee } //Take the direction the sword is swung. FUCK not controlling the swing direction more than just left/right :| - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); diff --git a/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs b/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs index a19e2edfe2..db33bf30e4 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_DecaysRetort.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Melee { CanBounce = 1f; projectile.timeLeft = (int)MaxTime; - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); if (CanLunge == 1f) diff --git a/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs b/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs index 743e5b75c7..34e83fd530 100644 --- a/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs +++ b/Projectiles/Melee/BrokenBiomeBlade_GrovetendersTouch.cs @@ -104,7 +104,7 @@ namespace CalamityMod.Projectiles.Melee { if (!initialized) //Initialization. create control points & shit) { - projectile.velocity = Owner.DirectionTo(Owner.Calamity().mouseWorld); + projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); Reach = MathHelper.Clamp((Owner.Center - Owner.Calamity().mouseWorld).Length(), MinReach, MaxReach); Main.PlaySound(SoundID.DD2_OgreSpit, projectile.Center); controlPoint1 = projectile.Center; @@ -145,7 +145,7 @@ namespace CalamityMod.Projectiles.Melee //Shmoove the player if a tile is hit. This movement always happens if the owner isnt on the ground, but will only happen if the projectile is above the player if they are standing on the ground) if (Collision.SolidCollision(projectile.position, 32, 32) && (Owner.velocity.Y != 0 || projectile.position.Y < Owner.position.Y)) { - Owner.velocity = Owner.DirectionTo(projectile.Center) * ReelBackStrenght; + Owner.velocity = Owner.SafeDirectionTo(projectile.Center, Vector2.Zero) * ReelBackStrenght; SnapCoyoteTime = 0f; } Main.PlaySound(SoundID.Item65, projectile.position); diff --git a/Projectiles/Melee/Galaxia_AndromedasStride.cs b/Projectiles/Melee/Galaxia_AndromedasStride.cs index 08bc19d94b..e77e013927 100644 --- a/Projectiles/Melee/Galaxia_AndromedasStride.cs +++ b/Projectiles/Melee/Galaxia_AndromedasStride.cs @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Melee if (State == 0f) { - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.Center = Owner.Center + (direction * 70f * ChargeDisplacement()); diff --git a/Projectiles/Melee/Galaxia_AriesWrath.cs b/Projectiles/Melee/Galaxia_AriesWrath.cs index 1d74281023..c454692c06 100644 --- a/Projectiles/Melee/Galaxia_AriesWrath.cs +++ b/Projectiles/Melee/Galaxia_AriesWrath.cs @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Melee NPC potentialTarget = TargetNext(target.Center, i); if (potentialTarget == null) break; - Projectile proj = Projectile.NewProjectileDirect(target.Center, target.DirectionTo(potentialTarget.Center) * 25f, ProjectileType(), (int)(damage * FourSeasonsGalaxia.AriesAttunement_OnHitBoltDamageReduction), 0, Owner.whoAmI, 0.9f, MathHelper.PiOver4 * 0.4f); + Projectile proj = Projectile.NewProjectileDirect(target.Center, target.SafeDirectionTo(potentialTarget.Center, Vector2.Zero) * 25f, ProjectileType(), (int)(damage * FourSeasonsGalaxia.AriesAttunement_OnHitBoltDamageReduction), 0, Owner.whoAmI, 0.9f, MathHelper.PiOver4 * 0.4f); proj.scale = 2f; } Array.Clear(excludedTargets, 0, 3); @@ -135,9 +135,9 @@ namespace CalamityMod.Projectiles.Melee projectile.velocity *= 10f; } if (projectile.velocity.AngleBetween(Owner.Center - projectile.Center) > MathHelper.PiOver4) - projectile.velocity = (projectile.velocity.ToRotation().AngleTowards(projectile.DirectionTo(Owner.Center).ToRotation(), MathHelper.Pi / 20f)).ToRotationVector2() * projectile.velocity.Length() * 0.98f; + projectile.velocity = (projectile.velocity.ToRotation().AngleTowards(projectile.SafeDirectionTo(Owner.Center, Vector2.Zero).ToRotation(), MathHelper.Pi / 20f)).ToRotationVector2() * projectile.velocity.Length() * 0.98f; else - projectile.velocity = (projectile.velocity.ToRotation().AngleTowards(projectile.DirectionTo(Owner.Center).ToRotation(), MathHelper.Pi)).ToRotationVector2() * projectile.velocity.Length() * 1.05f; + projectile.velocity = (projectile.velocity.ToRotation().AngleTowards(projectile.SafeDirectionTo(Owner.Center, Vector2.Zero).ToRotation(), MathHelper.Pi)).ToRotationVector2() * projectile.velocity.Length() * 1.05f; projectile.rotation = Main.GlobalTime * 25f; projectile.scale = MathHelper.Clamp((Owner.Center - projectile.Center).Length() / (FourSeasonsGalaxia.AriesAttunement_Reach * 0.5f), 0.3f, 2f); projectile.timeLeft = 4; @@ -163,12 +163,12 @@ namespace CalamityMod.Projectiles.Melee projectile.Center = projectile.Center.MoveTowards(Owner.Calamity().mouseWorld, 40f * ThrowDisplace()); if ((projectile.Center - Owner.Center).Length() > FourSeasonsGalaxia.AriesAttunement_Reach) - projectile.Center = Owner.Center + Owner.DirectionTo(projectile.Center) * FourSeasonsGalaxia.AriesAttunement_Reach; + projectile.Center = Owner.Center + Owner.SafeDirectionTo(projectile.Center, Vector2.Zero) * FourSeasonsGalaxia.AriesAttunement_Reach; projectile.rotation = Main.GlobalTime * 25f; //Make the owner look like theyre "holding" the sword bla bla Owner.heldProj = projectile.whoAmI; - projectile.velocity = Owner.DirectionTo(projectile.Center); + projectile.velocity = Owner.SafeDirectionTo(projectile.Center, Vector2.Zero); Owner.direction = Math.Sign(projectile.velocity.X); Owner.itemRotation = projectile.velocity.ToRotation(); if (Owner.direction != 1) @@ -197,14 +197,14 @@ namespace CalamityMod.Projectiles.Melee { float maxDistance = projectile.scale * 82f; Vector2 distance = Main.rand.NextVector2Circular(maxDistance, maxDistance); - Vector2 angularVelocity = Vector2.Normalize(distance.RotatedBy(MathHelper.PiOver2)) * 2f * (1f + distance.Length() / 15f); + Vector2 angularVelocity = Utils.SafeNormalize(distance.RotatedBy(MathHelper.PiOver2), Vector2.Zero) * 2f * (1f + distance.Length() / 15f); Particle glitter = new CritSpark(projectile.Center + distance, angularVelocity, Main.rand.Next(3) == 0 ? Color.HotPink : Color.Plum, Color.DarkOrchid, 1f + 1 * (distance.Length() / maxDistance), 10, 0.05f, 3f); GeneralParticleHandler.SpawnParticle(glitter); } float smokeDistance = projectile.scale * 62f; Vector2 smokePos = Main.rand.NextVector2Circular(smokeDistance, smokeDistance); - Vector2 smokeSpeed = Vector2.Normalize(smokePos.RotatedBy(MathHelper.PiOver2)) * 0.1f * (1f + smokePos.Length() / 15f); + Vector2 smokeSpeed = Utils.SafeNormalize(smokePos.RotatedBy(MathHelper.PiOver2), Vector2.Zero) * 0.1f * (1f + smokePos.Length() / 15f); Particle smoke = new HeavySmokeParticle(projectile.Center + smokePos, smokeSpeed, Color.Lerp(Color.Navy, Color.Indigo, (float)Math.Sin(Main.GlobalTime * 6f)), 30, Main.rand.NextFloat(0.4f, 1f) * projectile.scale, 0.8f, 0, false, 0, true); GeneralParticleHandler.SpawnParticle(smoke); diff --git a/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs b/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs index 85b2838aeb..36e4d598f5 100644 --- a/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs +++ b/Projectiles/Melee/Galaxia_AriesWrathConstellation.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Melee for (float i = 0 + Main.rand.NextFloat(0.2f, 0.5f); i < 1; i += Main.rand.NextFloat(0.2f, 0.5f)) { - offset = Main.rand.NextFloat(-50f, 50f) * Vector2.Normalize(SizeVector.RotatedBy(MathHelper.PiOver2)); + offset = Main.rand.NextFloat(-50f, 50f) * Utils.SafeNormalize(SizeVector.RotatedBy(MathHelper.PiOver2), Vector2.Zero); Star = new GenericSparkle(projectile.Center + SizeVector * i + offset, Vector2.Zero, Color.White, Color.Plum, Main.rand.NextFloat(1f, 1.5f), 20, 0f, 3f); GeneralParticleHandler.SpawnParticle(Star); @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Melee if (Main.rand.Next(3) == 0) { - offset = Main.rand.NextFloat(-50f, 50f) * Vector2.Normalize(SizeVector.RotatedBy(MathHelper.PiOver2)); + offset = Main.rand.NextFloat(-50f, 50f) * Utils.SafeNormalize(SizeVector.RotatedBy(MathHelper.PiOver2), Vector2.Zero); Star = new GenericSparkle(projectile.Center + SizeVector * i + offset, Vector2.Zero, Color.White, Color.Plum, Main.rand.NextFloat(1f, 1.5f), 20, 0f, 3f); GeneralParticleHandler.SpawnParticle(Star); diff --git a/Projectiles/Melee/Galaxia_PhoenixsPride.cs b/Projectiles/Melee/Galaxia_PhoenixsPride.cs index 01c93d026b..4f7b1bc07f 100644 --- a/Projectiles/Melee/Galaxia_PhoenixsPride.cs +++ b/Projectiles/Melee/Galaxia_PhoenixsPride.cs @@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Melee { Main.PlaySound(SoundID.Item90, projectile.Center); projectile.velocity = Vector2.Zero; - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); initialized = true; } @@ -104,7 +104,7 @@ namespace CalamityMod.Projectiles.Melee Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3; Main.PlaySound(SoundID.Item80, projectile.Center); - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); //PARTICLES LOTS OF PARTICLES LOTS OF SPARKLES YES YES MH YES YES for (int i = 0; i <= 8; i++) { @@ -207,17 +207,17 @@ namespace CalamityMod.Projectiles.Melee } float rotationAdjusted = MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi; - float mouseAngleAdjusted = MathHelper.WrapAngle(Owner.DirectionTo(Main.MouseWorld).ToRotation()) + MathHelper.Pi; + float mouseAngleAdjusted = MathHelper.WrapAngle(Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.One).ToRotation()) + MathHelper.Pi; float deltaAngleShoot = Math.Abs(MathHelper.WrapAngle(rotationAdjusted - mouseAngleAdjusted)); if (CanDirectFire && deltaAngleShoot < 0.1f) { if (Owner.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(Owner.Center, Owner.DirectionTo(Main.MouseWorld) * 15f, ProjectileType(), (int)(projectile.damage * FourSeasonsGalaxia.PhoenixAttunement_BoltDamageReduction), 0f, Owner.whoAmI, 0.1f, MathHelper.Pi * 0.02f); + Projectile.NewProjectile(Owner.Center, Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.One) * 15f, ProjectileType(), (int)(projectile.damage * FourSeasonsGalaxia.PhoenixAttunement_BoltDamageReduction), 0f, Owner.whoAmI, 0.1f, MathHelper.Pi * 0.02f); } CanDirectFire = false; - AngleReset = Owner.DirectionTo(Main.MouseWorld).ToRotation(); + AngleReset = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.One).ToRotation(); } @@ -225,7 +225,7 @@ namespace CalamityMod.Projectiles.Melee { float maxDistance = projectile.scale * 1.9f * 78f; Vector2 distance = Main.rand.NextVector2Circular(maxDistance, maxDistance); - Vector2 angularVelocity = Vector2.Normalize(distance.RotatedBy(MathHelper.PiOver2)) * 2f * (1f + distance.Length() / 15f); + Vector2 angularVelocity = Utils.SafeNormalize(distance.RotatedBy(MathHelper.PiOver2), Vector2.Zero) * 2f * (1f + distance.Length() / 15f); Particle glitter = new CritSpark(Owner.Center + distance, Owner.velocity + angularVelocity, Main.rand.Next(3) == 0 ? Color.Turquoise : Color.Coral, currentColor, 1f + 1 * (distance.Length() / maxDistance), 10, 0.05f, 3f); GeneralParticleHandler.SpawnParticle(glitter); } diff --git a/Projectiles/Melee/Galaxia_PolarisGaze.cs b/Projectiles/Melee/Galaxia_PolarisGaze.cs index 25bbdc9e7f..b4ae8b1a55 100644 --- a/Projectiles/Melee/Galaxia_PolarisGaze.cs +++ b/Projectiles/Melee/Galaxia_PolarisGaze.cs @@ -156,7 +156,7 @@ namespace CalamityMod.Projectiles.Melee Shred = 0; //Manage position and rotation - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); projectile.Center = Owner.Center + (direction * 60); diff --git a/Projectiles/Melee/Galaxia_PolarisGazeDash.cs b/Projectiles/Melee/Galaxia_PolarisGazeDash.cs index 987484119e..5241445e8a 100644 --- a/Projectiles/Melee/Galaxia_PolarisGazeDash.cs +++ b/Projectiles/Melee/Galaxia_PolarisGazeDash.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Melee //Explode into cosmic bolts for (int i = 0; i < 3; i++) { - Projectile blast = Projectile.NewProjectileDirect(Owner.Center, Owner.DirectionTo(target.Center).RotatedByRandom(MathHelper.PiOver4) * 30f, ProjectileType(), (int)(FourSeasonsGalaxia.PolarisAttunement_SlashBoltsDamage * Owner.meleeDamage), 0f, Owner.whoAmI, 0.55f, MathHelper.Pi * 0.01f); + Projectile blast = Projectile.NewProjectileDirect(Owner.Center, Owner.SafeDirectionTo(target.Center, Vector2.Zero).RotatedByRandom(MathHelper.PiOver4) * 30f, ProjectileType(), (int)(FourSeasonsGalaxia.PolarisAttunement_SlashBoltsDamage * Owner.meleeDamage), 0f, Owner.whoAmI, 0.55f, MathHelper.Pi * 0.01f); { blast.timeLeft = 100; } diff --git a/Projectiles/Melee/Galaxia_PolarisGazeStar.cs b/Projectiles/Melee/Galaxia_PolarisGazeStar.cs index a3ee2e6786..1d57f9f4c5 100644 --- a/Projectiles/Melee/Galaxia_PolarisGazeStar.cs +++ b/Projectiles/Melee/Galaxia_PolarisGazeStar.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Melee Main.PlaySound(SoundID.Item90, projectile.Center); initialized = true; - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); diff --git a/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs b/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs index 0b05a945d7..2ea73c22ad 100644 --- a/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs +++ b/Projectiles/Melee/MendedBiomeBlade_DecaysRetortDash.cs @@ -67,13 +67,11 @@ namespace CalamityMod.Projectiles.Melee Vector2 Shake = projectile.timeLeft < 15 ? Vector2.Zero : Vector2.One.RotatedByRandom(MathHelper.TwoPi) * (15 - projectile.timeLeft / 5f) * 0.5f; - Vector2 lineDirection = Vector2.Normalize(DashEnd - DashStart); int dist = (int)Vector2.Distance(DashEnd, DashStart) / 16; Vector2[] Nodes = new Vector2[dist + 1]; Nodes[0] = DashStart; Nodes[dist] = DashEnd; - for (int i = 1; i < dist + 1; i++) { Vector2 positionAlongLine = Vector2.Lerp(DashStart, DashEnd, i / (float)dist); //Get the position of the segment along the line diff --git a/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs b/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs index 68f4dd8bad..86ee6241a4 100644 --- a/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs +++ b/Projectiles/Melee/MendedBiomeBlade_ExtantAbhorrence.cs @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Melee if (State == 0f) { - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.Center = Owner.Center + (direction * 70f * ChargeDisplacement()); diff --git a/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrownedOrb.cs b/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrownedOrb.cs index 89c4b074c6..40a4ae7a46 100644 --- a/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrownedOrb.cs +++ b/Projectiles/Melee/MendedBiomeBlade_GestureForTheDrownedOrb.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Melee return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Bottom, projectile.Bottom - (Vector2.UnitY * scaleY * 110), scaleX * 40, ref collisionPoint); float halfLenght = 66f * projectile.scale; - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center + Vector2.Normalize(projectile.velocity.RotatedBy(MathHelper.PiOver2)) * halfLenght, projectile.Center - Vector2.Normalize(projectile.velocity.RotatedBy(MathHelper.PiOver2)) * halfLenght, 40f, ref collisionPoint); + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center + Utils.SafeNormalize(projectile.velocity.RotatedBy(MathHelper.PiOver2), Vector2.Zero) * halfLenght, projectile.Center - Utils.SafeNormalize(projectile.velocity.RotatedBy(MathHelper.PiOver2), Vector2.Zero) * halfLenght, 40f, ref collisionPoint); } public override void DrawBehind(int index, List drawCacheProjsBehindNPCsAndTiles, List drawCacheProjsBehindNPCs, List drawCacheProjsBehindProjectiles, List drawCacheProjsOverWiresUI) diff --git a/Projectiles/Melee/MendedBiomeBlade_GrovetendersEntanglingVines.cs b/Projectiles/Melee/MendedBiomeBlade_GrovetendersEntanglingVines.cs index 37ff452df6..291c7a08f5 100644 --- a/Projectiles/Melee/MendedBiomeBlade_GrovetendersEntanglingVines.cs +++ b/Projectiles/Melee/MendedBiomeBlade_GrovetendersEntanglingVines.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Melee float opacity = projectile.timeLeft > 10 ? 1 : projectile.timeLeft / 10f; Vector2 Shake = projectile.timeLeft < 15 ? Vector2.Zero : Vector2.One.RotatedByRandom(MathHelper.TwoPi) * (15 - projectile.timeLeft / 5f) * 0.5f; - Vector2 lineDirection = Vector2.Normalize(Target.Center - NPCfrom.Center); + Vector2 lineDirection = Utils.SafeNormalize(Target.Center - NPCfrom.Center, Vector2.Zero); int dist = (int)Vector2.Distance(Target.Center, NPCfrom.Center) / 16; Vector2[] Nodes = new Vector2[dist + 1]; Nodes[0] = NPCfrom.Center; diff --git a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs index 0ae5022b6c..0c379b589d 100644 --- a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs +++ b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.cs @@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Melee { Main.PlaySound(SoundID.Item90, projectile.Center); projectile.velocity = Vector2.Zero; - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); oldDirection = direction; initialized = true; @@ -102,7 +102,7 @@ namespace CalamityMod.Projectiles.Melee { CurrentState = 1f; Main.PlaySound(SoundID.Item80, projectile.Center); - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); //PARTICLES LOTS OF PARTICLES LOTS OF SPARKLES YES YES MH YES YES for (int i = 0; i <= 8; i++) { diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs index 79baa9e483..c2d5efb1a0 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeur.cs @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(projectile.Center, new Vector3(1f, 0.56f, 0.56f) * ShredRatio); //Manage position and rotation - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); projectile.Center = Owner.Center + (direction * 60); diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeurShot.cs b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeurShot.cs index ffc2a1187f..b1ca5d626c 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeurShot.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueAridGrandeurShot.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = (int)(30f + ShredRatio * 30f); initialized = true; - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs b/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs index 987eec2b16..0da458e866 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueBitingEmbrace.cs @@ -129,7 +129,7 @@ namespace CalamityMod.Projectiles.Melee break; } - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs b/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs index 1426434789..46e010cd88 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueDecaysRetort.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Projectiles.Melee { CanBounce = 1f; projectile.timeLeft = (int)MaxTime; - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); if (CanLunge == 1f && !ChargedUp) diff --git a/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs b/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs index 14461e6d76..ff1c46dbec 100644 --- a/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs +++ b/Projectiles/Melee/MendedBiomeBlade_TrueGrovetendersTouch.cs @@ -158,7 +158,7 @@ namespace CalamityMod.Projectiles.Melee { if (!initialized) //Initialization. create control points & shit) { - projectile.velocity = Owner.DirectionTo(Owner.Calamity().mouseWorld); + projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); Reach = MathHelper.Clamp((Owner.Center - Owner.Calamity().mouseWorld).Length(), MinReach, MaxReach); Main.PlaySound(SoundID.DD2_OgreSpit, projectile.Center); controlPoint1 = projectile.Center; @@ -201,7 +201,7 @@ namespace CalamityMod.Projectiles.Melee //Shmoove the player if a tile is hit. This movement always happens if the owner isnt on the ground, but will only happen if the projectile is above the player if they are standing on the ground) if (Collision.SolidCollision(projectile.position, 32, 32) && (Owner.velocity.Y != 0 || projectile.position.Y < Owner.position.Y)) { - Owner.velocity = Owner.DirectionTo(projectile.Center) * ReelBackStrenght; + Owner.velocity = Owner.SafeDirectionTo(projectile.Center, Vector2.Zero) * ReelBackStrenght; SnapCoyoteTime = 0f; } Main.PlaySound(SoundID.Item65, projectile.position); diff --git a/Projectiles/Melee/TrueAncientBlast.cs b/Projectiles/Melee/TrueAncientBlast.cs index c42d4f6454..3cc36c5c6f 100644 --- a/Projectiles/Melee/TrueAncientBlast.cs +++ b/Projectiles/Melee/TrueAncientBlast.cs @@ -33,13 +33,10 @@ namespace CalamityMod.Projectiles.Melee const float MaxTime = 20; public float Timer => MaxTime - projectile.timeLeft; - public ref float angle => ref projectile.ai[0]; - public ref float lenght => ref projectile.ai[1]; + public ref float HitCounter => ref projectile.ai[0]; public Player Owner => Main.player[projectile.owner]; - public Vector2 lineVector => angle.ToRotationVector2() * lenght; - public override void SetDefaults() { projectile.melee = true; @@ -55,9 +52,11 @@ namespace CalamityMod.Projectiles.Melee public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { float collisionPoint = 0f; - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + lineVector, 20f, ref collisionPoint); + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity, 20f, ref collisionPoint); } + public override bool ShouldUpdatePosition() => false; + public override void AI() { if (Timer == 0) @@ -65,7 +64,7 @@ namespace CalamityMod.Projectiles.Melee Particle Star = new GenericSparkle(projectile.Center, Vector2.Zero, Color.White, Color.HotPink, Main.rand.NextFloat(2f, 2.5f), 20, 0.1f, 3f); GeneralParticleHandler.SpawnParticle(Star); - Star = new GenericSparkle(projectile.Center + lineVector, Vector2.Zero, Color.White, Color.PaleGoldenrod, Main.rand.NextFloat(2f, 2.5f), 20, 0.1f, 3f); + Star = new GenericSparkle(projectile.Center + projectile.velocity, Vector2.Zero, Color.White, Color.PaleGoldenrod, Main.rand.NextFloat(2f, 2.5f), 20, 0.1f, 3f); GeneralParticleHandler.SpawnParticle(Star); Main.PlaySound(SoundID.Item84, projectile.Center); @@ -80,12 +79,19 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < 10; i++) { - Vector2 particleSpeed = angle.ToRotationVector2().RotatedByRandom(MathHelper.PiOver4 * 0.8f) * Main.rand.NextFloat(2.6f, 4f); + Vector2 particleSpeed = Utils.SafeNormalize(projectile.velocity, Vector2.Zero).RotatedByRandom(MathHelper.PiOver4 * 0.8f) * Main.rand.NextFloat(2.6f, 4f); Particle energyLeak = new SquishyLightParticle(target.Center, particleSpeed, Main.rand.NextFloat(0.3f, 0.6f), Color.Cyan, 60, 1, 1.5f, hueShift: 0.02f); GeneralParticleHandler.SpawnParticle(energyLeak); } } + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + //Add some damage falloff + damage = (int)(damage * Math.Pow((1 - TrueArkoftheAncients.blastFalloffStrenght), HitCounter * TrueArkoftheAncients.blastFalloffSpeed)); + HitCounter++; + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D sword = GetTexture("CalamityMod/Items/Weapons/Melee/TrueArkoftheAncients"); @@ -93,6 +99,8 @@ namespace CalamityMod.Projectiles.Melee float displace = 10 * (1f + ((float)Math.Sin(Timer / MaxTime * MathHelper.Pi) * 0.8f)); + float angle = projectile.velocity.ToRotation(); + float drawRotation = angle + MathHelper.PiOver4; Vector2 drawOrigin = new Vector2(0f, sword.Height); Vector2 drawOffset = Owner.Center + angle.ToRotationVector2() * displace - Main.screenPosition; @@ -111,7 +119,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 origin = new Vector2(tex.Width / 2f, tex.Height); float size = Timer / MaxTime > 0.5f ? (float)Math.Sin(Timer / MaxTime * MathHelper.Pi) * 0.2f + 0.8f : (float)Math.Sin(Timer / MaxTime * MathHelper.Pi); size *= 3; - Vector2 scale = new Vector2(size, lenght / tex.Height); + Vector2 scale = new Vector2(size, projectile.velocity.Length() / tex.Height); spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, Color.LightPink, rot, origin, scale, SpriteEffects.None, 0); //Cap the lines @@ -119,7 +127,7 @@ namespace CalamityMod.Projectiles.Melee scale = new Vector2(size, size); origin = new Vector2(cap.Width / 2f, cap.Height); spriteBatch.Draw(cap, projectile.Center - Main.screenPosition, null, Color.LightPink, rot + MathHelper.Pi, origin, scale, SpriteEffects.None, 0); - spriteBatch.Draw(cap, projectile.Center + lineVector - Main.screenPosition, null, Color.LightPink, rot, origin, scale, SpriteEffects.None, 0); + spriteBatch.Draw(cap, projectile.Center + projectile.velocity - Main.screenPosition, null, Color.LightPink, rot, origin, scale, SpriteEffects.None, 0); spriteBatch.End(); diff --git a/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs b/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs index 61be93f241..80ac0f3cf6 100644 --- a/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs +++ b/Projectiles/Melee/TrueArkOfTheAncients_ParryHoldout.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee public override string Texture => "CalamityMod/Items/Weapons/Melee/TrueArkoftheAncients"; private bool initialized = false; - const float MaxTime = 160; + const float MaxTime = 340; static float ParryTime = 15; public Vector2 DistanceFromPlayer => projectile.velocity * 10 * (1f + ((float)Math.Sin(Timer / ParryTime * MathHelper.Pi) * 0.8f)); public float Timer => MaxTime - projectile.timeLeft; @@ -96,7 +96,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = (int)MaxTime; Main.PlaySound(SoundID.DD2_SkyDragonsFuryShot, projectile.Center); - projectile.velocity = Owner.DirectionTo(Owner.Calamity().mouseWorld); + projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); projectile.velocity.Normalize(); projectile.rotation = projectile.velocity.ToRotation(); @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Melee //Manage position and rotation projectile.Center = Owner.Center + DistanceFromPlayer ; - projectile.scale = 1.4f + ((float)Math.Sin(Timer / MaxTime * MathHelper.Pi) * 0.6f); //SWAGGER + projectile.scale = 1.4f + ((float)Math.Sin(Timer / 160 * MathHelper.Pi) * 0.6f); //SWAGGER if (Timer > ParryTime) return; @@ -136,7 +136,7 @@ namespace CalamityMod.Projectiles.Melee //Bounce off the player if they are in the air if (Owner.velocity.Y != 0) - Owner.velocity += Vector2.Normalize(Owner.Center - proj.Center) * 2; + Owner.velocity += Utils.SafeNormalize(Owner.Center - proj.Center, Vector2.Zero) * 2; break; diff --git a/Projectiles/Melee/TrueBiomeBlade_ChainedMeatHook.cs b/Projectiles/Melee/TrueBiomeBlade_ChainedMeatHook.cs index f6d97f1081..b42962727c 100644 --- a/Projectiles/Melee/TrueBiomeBlade_ChainedMeatHook.cs +++ b/Projectiles/Melee/TrueBiomeBlade_ChainedMeatHook.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Melee { if (projectile.timeLeft == MaxTwirlTime) { - projectile.velocity = Owner.DirectionTo(Owner.Calamity().mouseWorld); + projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); Main.PlaySound(SoundID.Item71, projectile.Center); for (int i = 0; i < 4; i++) { diff --git a/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs b/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs index 1b2ced5d6c..f0f9c8539a 100644 --- a/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs +++ b/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChained.cs @@ -170,7 +170,7 @@ namespace CalamityMod.Projectiles.Melee return; } - projectile.velocity = Owner.DirectionTo(Owner.Calamity().mouseWorld); + projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); projectile.velocity.Normalize(); projectile.rotation = projectile.velocity.ToRotation(); projectile.Center = Owner.Center + (projectile.velocity * 60); @@ -326,7 +326,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 directionFromHead = direction.RotatedBy(MathHelper.ToRadians(MathHelper.Lerp(0, 160f * flip, (float)Math.Sin(randomNumber * MathHelper.Pi)))) * MathHelper.Lerp(130f, 200f, MathHelper.Clamp((float)Math.Sin(randomNumber * MathHelper.Pi) - 0.5f, 0f, 1f) * 2f); control2 = control3 + directionFromHead; - Vector2 directionFromSecondToLastPoint = Vector2.Normalize(directionFromHead.RotatedBy(MathHelper.Pi - MathHelper.ToRadians(MathHelper.Lerp(80f * flip, 110f * flip, (float)Math.Sin(randomNumber * MathHelper.Pi))))) * MathHelper.Lerp(120f, 280f, (float)Math.Sin(randomNumber * MathHelper.Pi)); + Vector2 directionFromSecondToLastPoint = Utils.SafeNormalize(directionFromHead.RotatedBy(MathHelper.Pi - MathHelper.ToRadians(MathHelper.Lerp(80f * flip, 110f * flip, (float)Math.Sin(randomNumber * MathHelper.Pi)))), Vector2.Zero) * MathHelper.Lerp(120f, 280f, (float)Math.Sin(randomNumber * MathHelper.Pi)); control1 = control2 + directionFromSecondToLastPoint; control3 += Vector2.UnitX.RotatedBy(MathHelper.TwoPi * seed1) * seed3 * 30f; diff --git a/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs b/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs index 6d639b49bd..2ce54768e8 100644 --- a/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs +++ b/Projectiles/Melee/TrueBiomeBlade_MercurialTides.cs @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Melee if (State == 0f) { - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.Center = Owner.Center + (direction * 70f * ChargeDisplacement()); diff --git a/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs b/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs index 5321a2e6d2..9d310bf8a2 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SanguineFury.cs @@ -143,7 +143,7 @@ namespace CalamityMod.Projectiles.Melee Lighting.AddLight(projectile.Center, new Vector3(1f, 0.56f, 0.56f) * ShredRatio); //Manage position and rotation - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); projectile.Center = Owner.Center + (direction * 60); @@ -176,7 +176,7 @@ namespace CalamityMod.Projectiles.Melee { Owner.Calamity().LungingDown = true; Owner.fallStart = (int)(Owner.position.Y / 16f); - Owner.velocity = Owner.DirectionTo(Wheel.Center) * 60f; + Owner.velocity = Owner.SafeDirectionTo(Wheel.Center, Vector2.Zero) * 60f; if (Owner.Distance(Wheel.Center) < 60f) Wheel.active = false; diff --git a/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs b/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs index ef90d89c5e..3915cde832 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SanguineFuryWheel.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Melee Main.PlaySound(SoundID.Item90, projectile.Center); initialized = true; - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); projectile.rotation = direction.ToRotation(); diff --git a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs index a0f8867dad..0bbca6f07c 100644 --- a/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs +++ b/Projectiles/Melee/TrueBiomeBlade_SwordsmithsPride.cs @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Melee { Main.PlaySound(SoundID.Item90, projectile.Center); projectile.velocity = Vector2.Zero; - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); direction.Normalize(); initialized = true; } @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Melee { CurrentState = 1f; Main.PlaySound(SoundID.Item80, projectile.Center); - direction = Owner.DirectionTo(Owner.Calamity().mouseWorld); + direction = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.Zero); //PARTICLES LOTS OF PARTICLES LOTS OF SPARKLES YES YES MH YES YES for (int i = 0; i <= 8; i++) { @@ -179,33 +179,33 @@ namespace CalamityMod.Projectiles.Melee if (sightLine == null) { - sightLine = new LineVFX(Owner.Center, Owner.DirectionTo(Owner.Calamity().mouseWorld), 0.2f, Color.HotPink, false); + sightLine = new LineVFX(Owner.Center, Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.One), 0.2f, Color.HotPink, false); GeneralParticleHandler.SpawnParticle(sightLine); } else { - sightLine.Position = Owner.Center + Owner.DirectionTo(Owner.Calamity().mouseWorld) * projectile.scale * 1.88f * 40; - (sightLine as LineVFX).LineVector = Owner.DirectionTo(Owner.Calamity().mouseWorld) * projectile.scale * 1.88f * 38f; + sightLine.Position = Owner.Center + Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.One) * projectile.scale * 1.88f * 40; + (sightLine as LineVFX).LineVector = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld, Vector2.One) * projectile.scale * 1.88f * 38f; sightLine.Scale = 0.2f; sightLine.Time = 0; sightLine.Color = currentColor * 0.7f; } float rotationAdjusted = MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi; - float mouseAngleAdjusted = MathHelper.WrapAngle(Owner.DirectionTo(Main.MouseWorld).ToRotation()) + MathHelper.Pi; + float mouseAngleAdjusted = MathHelper.WrapAngle(Owner.SafeDirectionTo(Main.MouseWorld, Vector2.One).ToRotation()) + MathHelper.Pi; float deltaAngleShoot = Math.Abs(MathHelper.WrapAngle(rotationAdjusted - mouseAngleAdjusted)); if (CanDirectFire && deltaAngleShoot < 0.1f) { - Particle Blink = new GenericSparkle(Owner.Center + Owner.DirectionTo(Main.MouseWorld) * projectile.scale * 1.88f * 78f, Owner.velocity, Color.White, currentColor, 1.5f, 10, 0.1f, 3f); + Particle Blink = new GenericSparkle(Owner.Center + Owner.SafeDirectionTo(Main.MouseWorld, Vector2.One) * projectile.scale * 1.88f * 78f, Owner.velocity, Color.White, currentColor, 1.5f, 10, 0.1f, 3f); GeneralParticleHandler.SpawnParticle(Blink); if (Owner.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(Owner.Center, Owner.DirectionTo(Main.MouseWorld) * 15f, ProjectileType(), (int)(projectile.damage * OmegaBiomeBlade.WhirlwindAttunement_BeamDamageReduction), 0f, Owner.whoAmI); + Projectile.NewProjectile(Owner.Center, Owner.SafeDirectionTo(Main.MouseWorld, Vector2.One) * 15f, ProjectileType(), (int)(projectile.damage * OmegaBiomeBlade.WhirlwindAttunement_BeamDamageReduction), 0f, Owner.whoAmI); } CanDirectFire = false; - AngleReset = Owner.DirectionTo(Main.MouseWorld).ToRotation(); + AngleReset = Owner.SafeDirectionTo(Main.MouseWorld, Vector2.One).ToRotation(); } @@ -213,7 +213,7 @@ namespace CalamityMod.Projectiles.Melee { float maxDistance = projectile.scale * 1.9f * 78f; Vector2 distance = Main.rand.NextVector2Circular(maxDistance, maxDistance); - Vector2 angularVelocity = Vector2.Normalize(distance.RotatedBy(MathHelper.PiOver2)) * 2f * (1f + distance.Length() / 15f); + Vector2 angularVelocity = Utils.SafeNormalize(distance.RotatedBy(MathHelper.PiOver2), Vector2.Zero) * 2f * (1f + distance.Length() / 15f); Particle glitter = new CritSpark(Owner.Center + distance, Owner.velocity + angularVelocity, Color.White, currentColor, 1f + 1 * (distance.Length() / maxDistance), 10, 0.05f, 3f); GeneralParticleHandler.SpawnParticle(glitter); }