From 4e7cad2c0b2ab6dc95088efe462633fdbbe68e8c Mon Sep 17 00:00:00 2001 From: IbanPlay <56191483+IbanPlay@users.noreply.github.com> Date: Mon, 14 Feb 2022 07:06:03 +0100 Subject: [PATCH] projectiles,, --- Items/Weapons/Melee/ArkoftheCosmos.cs | 5 +- Projectiles/Melee/RendingNeedle.cs | 134 ++++++++++++++++++ .../{GalacticNeedle.png => RendingNeedle.png} | Bin Projectiles/Melee/SolarNeedle.cs | 2 +- 4 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 Projectiles/Melee/RendingNeedle.cs rename Projectiles/Melee/{GalacticNeedle.png => RendingNeedle.png} (100%) diff --git a/Items/Weapons/Melee/ArkoftheCosmos.cs b/Items/Weapons/Melee/ArkoftheCosmos.cs index abc87cd58f..b9466e0543 100644 --- a/Items/Weapons/Melee/ArkoftheCosmos.cs +++ b/Items/Weapons/Melee/ArkoftheCosmos.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee public static float SlashBoltsDamageMultiplier = 0.2f; public static float SnapBoltsDamageMultiplier = 0.1f; - public static float SwirlBoltAmount = 10f; + public static float SwirlBoltAmount = 8f; public static float SwirlBoltDamageMultiplier = 0.3f; //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" + @@ -144,8 +144,7 @@ namespace CalamityMod.Items.Weapons.Melee if (scissorState != 2) { Vector2 throwVector = new Vector2(speedX, speedY); - float empoweredNeedles = Charge > 0 ? 1f : 0f; - Projectile.NewProjectile(player.Center + Vector2.Normalize(throwVector) * 20, new Vector2(speedX, speedY) * 1.4f, ProjectileType(), (int)(damage * NeedleDamageMultiplier), knockBack, player.whoAmI, empoweredNeedles); + Projectile.NewProjectile(player.Center + Vector2.Normalize(throwVector) * 20, new Vector2(speedX, speedY) * 1.4f, ProjectileType(), (int)(damage * NeedleDamageMultiplier), knockBack, player.whoAmI); } Combo += 1; diff --git a/Projectiles/Melee/RendingNeedle.cs b/Projectiles/Melee/RendingNeedle.cs new file mode 100644 index 0000000000..b3199d0cb7 --- /dev/null +++ b/Projectiles/Melee/RendingNeedle.cs @@ -0,0 +1,134 @@ +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.CalPlayer; +using CalamityMod.DataStructures; +using CalamityMod.Particles; +using CalamityMod.Items.Weapons.Melee; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; +using static CalamityMod.CalamityUtils; + + +namespace CalamityMod.Projectiles.Melee +{ + public class RendingNeedle : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rending Needle"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + const float MaxTime = 30; + public float Timer => MaxTime - projectile.timeLeft; + + public override void SetDefaults() + { + projectile.width = projectile.height = 32; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.timeLeft = (int)MaxTime; + projectile.melee = true; + projectile.tileCollide = false; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float collisionPoint = 0f; + float bladeLenght = 44f * projectile.scale; + Vector2 start = -Utils.SafeNormalize(projectile.velocity, Vector2.Zero) * 16f; + + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center + start, projectile.Center + start + Utils.SafeNormalize(projectile.velocity, Vector2.Zero) * bladeLenght, 24, ref collisionPoint); + } + + public override void AI() + { + projectile.scale = 2.4f; + projectile.Opacity = 0.6f; + Lighting.AddLight(projectile.Center, 0.75f, 1f, 0.24f); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + projectile.velocity *= (1 - (float)Math.Pow(Timer / MaxTime, 3) * 0.3f); + + if (Main.rand.Next(2) == 0) + { + Particle smoke = new HeavySmokeParticle(projectile.Center, projectile.velocity * 0.5f, Color.Lerp(Color.DodgerBlue, Color.MediumVioletRed, (float)Math.Sin(Main.GlobalTime * 6f)), 30, Main.rand.NextFloat(0.6f, 1.2f) * projectile.scale * 0.6f, 0.28f, 0, false, 0, true); + GeneralParticleHandler.SpawnParticle(smoke); + + if (Main.rand.Next(3) == 0) + { + Particle smokeGlow = new HeavySmokeParticle(projectile.Center, projectile.velocity * 0.5f, Main.hslToRgb(Main.rand.NextFloat(), 1, 0.7f), 20, Main.rand.NextFloat(0.4f, 0.7f) * projectile.scale * 0.6f, 0.8f, 0, true, 0.05f, true); + GeneralParticleHandler.SpawnParticle(smokeGlow); + } + } + + if (projectile.velocity.Length() < 1.0f) + projectile.Kill(); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.timeLeft > 35) + return false; + + Texture2D texture = GetTexture("CalamityMod/Projectiles/Melee/RendingNeedle"); + + + DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + Texture2D starTexture = GetTexture("CalamityMod/Particles/Sparkle"); + Texture2D bloomTexture = GetTexture("CalamityMod/Particles/BloomCircle"); + //Ajust the bloom's texture to be the same size as the star's + float properBloomSize = (float)starTexture.Height / (float)bloomTexture.Height; + + Color color = Main.hslToRgb((Main.GlobalTime * 0.6f) % 1, 1, 0.85f); + float rotation = Main.GlobalTime * 8f; + + Vector2 sparkCenter = projectile.Center - Utils.SafeNormalize(projectile.velocity, Vector2.Zero) * 30.5f - Main.screenPosition; + + spriteBatch.Draw(bloomTexture, sparkCenter, null, color* 0.5f, 0, bloomTexture.Size() / 2f, 4 * properBloomSize, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, sparkCenter, null, color * 0.5f, rotation + MathHelper.PiOver4, starTexture.Size() / 2f, 2 * 0.75f, SpriteEffects.None, 0); + spriteBatch.Draw(starTexture, sparkCenter, null, Color.White, rotation, starTexture.Size() / 2f, 2, SpriteEffects.None, 0); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + + return false; + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.DD2_WitherBeastDeath, projectile.Center); + for (int i = 0; i < 10; i++) + { + Vector2 particleSpeed = Main.rand.NextVector2CircularEdge(1, 1) * Main.rand.NextFloat(1.2f, 2.3f); + Particle energyLeak = new SquishyLightParticle(projectile.Center + Utils.SafeNormalize(projectile.velocity, Vector2.Zero) * 40f, particleSpeed, Main.rand.NextFloat(0.3f, 0.6f), Color.Cyan, 60, 1, 1.5f, hueShift: 0.02f); + GeneralParticleHandler.SpawnParticle(energyLeak); + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + Vector2 particleOrigin = target.Hitbox.Size().Length() < 140 ? target.Center : projectile.Center + projectile.rotation.ToRotationVector2() * 60f; + for (int i = 0; i < 10; i++) + { + Vector2 particleSpeed = Main.rand.NextVector2CircularEdge(1, 1) * Main.rand.NextFloat(2.6f, 4f); + Particle energyLeak = new SquishyLightParticle(particleOrigin, particleSpeed, Main.rand.NextFloat(0.3f, 0.6f), Color.Cyan, 60, 1, 1.5f, hueShift: 0.02f); + GeneralParticleHandler.SpawnParticle(energyLeak); + } + } + } +} \ No newline at end of file diff --git a/Projectiles/Melee/GalacticNeedle.png b/Projectiles/Melee/RendingNeedle.png similarity index 100% rename from Projectiles/Melee/GalacticNeedle.png rename to Projectiles/Melee/RendingNeedle.png diff --git a/Projectiles/Melee/SolarNeedle.cs b/Projectiles/Melee/SolarNeedle.cs index fa030d57c9..84d04bd39d 100644 --- a/Projectiles/Melee/SolarNeedle.cs +++ b/Projectiles/Melee/SolarNeedle.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee { public override void SetStaticDefaults() { - DisplayName.SetDefault("SolarNeedle"); + DisplayName.SetDefault("Solar Needle"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; ProjectileID.Sets.TrailingMode[projectile.type] = 2; }