diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 0a201a8a45..f945166455 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -709,6 +709,7 @@ namespace CalamityMod.CalPlayer #region Accessory public bool shieldOfTheHighRulerDashVelocityBoosted = false; public bool luxorsGift = false; + public bool luxorHit = false; public bool fungalSymbiote = false; public bool trinketOfChi = false; public bool gladiatorSword = false; @@ -2770,6 +2771,7 @@ namespace CalamityMod.CalPlayer #region Buffs, Debuffs, Counters, and Nonsense heldGaelsLastFrame = false; gaelSwipes = 0; + luxorHit = false; arsenalCooldown = 0; andromedaState = AndromedaPlayerState.Inactive; planarSpeedBoost = 0; diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 1766744907..62ee93be7f 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -146,6 +146,9 @@ namespace CalamityMod.CalPlayer // Ursa Sergeant slash cooldown is reset on kill if (ursaSergeant && target.life <= 0 && target.realLife == -1) ursaSergeantCooldown = (int)MathHelper.Clamp(ursaSergeantCooldown - 180, 0, 300); + + if (luxorsGift) + luxorHit = true; // Transformer gives +2 blobs on kill, which are stored then given to you one by one (so it can't spawn more than one on a single frame) if (transformer && Player.Calamity().transformerCooldown == 0 && target.life <= 0 && target.realLife == -1) @@ -307,6 +310,9 @@ namespace CalamityMod.CalPlayer if (ursaSergeant && target.life <= 0 && target.realLife == -1) ursaSergeantCooldown = (int)MathHelper.Clamp(ursaSergeantCooldown - UrsaSergeant.CooldownReducedPerKill, 0, UrsaSergeant.MaxCooldown); + if (luxorsGift && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType()) + luxorHit = true; + // Transformer gives +2 blobs on kill, which are stored then given to you one by one (so it can't spawn more than one on a single frame) if (transformer && Player.Calamity().transformerCooldown == 0 && target.life <= 0 && target.realLife == -1) { diff --git a/Items/Accessories/LuxorsGift.cs b/Items/Accessories/LuxorsGift.cs index bd3acd5dff..f2f6c4ffa8 100644 --- a/Items/Accessories/LuxorsGift.cs +++ b/Items/Accessories/LuxorsGift.cs @@ -1,17 +1,43 @@ -using CalamityMod.CalPlayer; +using System; +using CalamityMod.CalPlayer; +using CalamityMod.Cooldowns; +using CalamityMod.NPCs; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Accessories { public class LuxorsGift : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + + public const int meleeAttackSpeed = 100; + public const int rangedAttackSpeed = 25; + public const int magicAttackSpeed = 75; + public const int summonerAttackSpeed = 140; + public const int rogueAttackSpeed = 36; // Rogue has a 12 frame delay between it's two shots, so it's actaully a bit slower than you'd think + public const int classlessAttackSpeed = 50; + + public const int meleeDamage = 16; + public const int rangedDamage = 5; + public const int magicDamage = 13; + public const int summonerDamage = 22; + public const int rogueDamage = 8; + public const int classlessDamage = 9; + + public const int luxArmorPen = 35; // Remember kids, If a Shark Tooth Necklace approaches you, run away and contact your nearest trusted adult public override void SetDefaults() { - Item.width = 58; - Item.height = 48; + Item.width = 66; + Item.height = 46; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.accessory = true; @@ -21,6 +47,11 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.luxorsGift = true; + + if (player.ownedProjectileCounts[ProjectileType()] < 1 && !player.dead) + { + Projectile lux = Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.Center, Vector2.Zero, ProjectileType(), 0, 0f, player.whoAmI); + } } } } diff --git a/Items/Accessories/LuxorsGift.png b/Items/Accessories/LuxorsGift.png index f47ea32f11..df068e334c 100644 Binary files a/Items/Accessories/LuxorsGift.png and b/Items/Accessories/LuxorsGift.png differ diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 900fbab16d..3375430db0 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -343,84 +343,6 @@ namespace CalamityMod.Items player.statMana = 0; } - if (modPlayer.luxorsGift && !item.channel) - { - // useTime 9 = 0.9 useTime 2 = 0.2 - float damageMult = 1f; - if (item.useTime < 10) - damageMult -= (10 - item.useTime) / 10f; - - float newDamage = damage * damageMult; - - if (player.whoAmI == Main.myPlayer) - { - if (item.CountsAsClass()) - { - int meleeDamage = (int)(newDamage * 0.25f); - - if (meleeDamage >= 1) - { - int projectile = Projectile.NewProjectile(playerSource, position, velocity * 0.5f, ModContent.ProjectileType(), (int)meleeDamage, 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].DamageType = DamageClass.Generic; - } - } - else if (item.CountsAsClass()) - { - int throwingDamage = (int)(newDamage * 0.2f); - - if (throwingDamage >= 1) - { - int projectile = Projectile.NewProjectile(playerSource, position, velocity, ModContent.ProjectileType(), (int)throwingDamage, 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].DamageType = DamageClass.Generic; - } - } - else if (item.CountsAsClass()) - { - // This projectile is channeled and has no cooldown unless the gun fires - // The damage of the projectile is also always the max damage of the weapon, and the shot damage is calculated based off of that - // You can see how this may cause issues - // The projectile is fired inside of the scope's code instead - if (type != ModContent.ProjectileType()) - { - int rangedDamage = (int)(newDamage * 0.15f); - - if (rangedDamage >= 1) - { - int projectile = Projectile.NewProjectile(playerSource, position, velocity * 1.5f, ModContent.ProjectileType(), (int)rangedDamage, 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].DamageType = DamageClass.Generic; - } - } - } - else if (item.CountsAsClass()) - { - int magicDamage = (int)(newDamage * 0.3f); - - if (magicDamage >= 1) - { - int projectile = Projectile.NewProjectile(playerSource, position, velocity, ModContent.ProjectileType(), (int)magicDamage, 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile].DamageType = DamageClass.Generic; - } - } - else if (item.CountsAsClass() && player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) - { - if (damage >= 1) - { - int summonDamage = item.damage; - - int projectile = Projectile.NewProjectile(playerSource, position, Vector2.Zero, ModContent.ProjectileType(), summonDamage, 0f, player.whoAmI); - if (projectile.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[projectile].DamageType = DamageClass.Generic; - Main.projectile[projectile].originalDamage = item.damage; - } - } - } - } - } if (modPlayer.bloodflareMage && modPlayer.canFireBloodflareMageProjectile) { if (item.CountsAsClass() && !item.channel) diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 324611eead..c9df6d6cf0 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -1055,8 +1055,9 @@ LuxorsGift: { DisplayName: Luxor's Gift Tooltip: ''' - Weapons fire unique projectiles based on their damage type - Some weapons are unable to receive this bonus + Summons a scarab launcher that follows you closely + The scarab fires different projectiles at enemies depending on what class the held weapon belongs to + When not in use, the scarab will condense itself into a small orb of light ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index 98b90a5e98..6cb0e05a6f 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -80,6 +80,8 @@ JewelSpike.DisplayName: Spike KelvinCatalystStar.DisplayName: Kelvin Catalyst Star LeviAmberDash.DisplayName: Riptide Slam LunicBeam.DisplayName: Lunic Seeker +Luxor.DisplayName: Luxor +LuxorsGiftClassless.DisplayName: Luxor's Classless MagnusBeam.DisplayName: Magnus Seeker MagnusBoom.DisplayName: Nebula Blast MythrilFlare.DisplayName: Mythril Flare @@ -98,6 +100,7 @@ PlaguePulse.DisplayName: Plague Pulse PoisonousSeawater.DisplayName: Seawater PscTransformAnimation.DisplayName: Psc Transform Animation PscTransformRocks.DisplayName: Psc Transform Rocks +PuddleSplash.DisplayName: Puddle Splash ReaverOrb.DisplayName: Reaver Orb ReaverThornBase.DisplayName: Thorn RedLabSeeker.DisplayName: Seeking Mechanism @@ -145,4 +148,3 @@ YanmeisKnifeSlash.DisplayName: Yanmei's Knife YellowLabSeeker.DisplayName: Seeking Mechanism VoidofExtinctionCrit.DisplayName: Void of Extinction Crit XykDeathAnim.DisplayName: Xyk Death Animation -PuddleSplash.DisplayName: Puddle Splash diff --git a/Projectiles/Magic/LuxorsGiftMagic.cs b/Projectiles/Magic/LuxorsGiftMagic.cs index aaeb7a4d68..ada0659e91 100644 --- a/Projectiles/Magic/LuxorsGiftMagic.cs +++ b/Projectiles/Magic/LuxorsGiftMagic.cs @@ -1,5 +1,8 @@ using System; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,69 +17,87 @@ namespace CalamityMod.Projectiles.Magic ProjectileID.Sets.TrailCacheLength[Type] = 10; ProjectileID.Sets.TrailingMode[Type] = 1; } - + public float velLerp => Utils.GetLerpValue(1, 8, Projectile.velocity.Length(), true); public override void SetDefaults() { Projectile.width = 18; - Projectile.height = 18; + Projectile.height = 36; Projectile.friendly = true; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = 2; - Projectile.alpha = 255; - Projectile.timeLeft = 240; + Projectile.timeLeft = 360; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.localNPCHitCooldown = -1; + Projectile.extraUpdates = 2; + Projectile.tileCollide = false; } - public override void AI() { + Lighting.AddLight(Projectile.Center, Color.Gold.ToVector3() * 0.35f); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (Projectile.localAI[0] == 0f) + if (Projectile.timeLeft == 360) + Projectile.velocity *= 0.1f; + if (Projectile.velocity.Length() < 8) + Projectile.velocity *= 1.01f; + /* + Vector2 dustVel = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.5f) * Main.rand.NextFloat(0.8f, 1.3f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4), ModContent.DustType(), dustVel * Main.rand.NextFloat(0.5f, 1.2f)); + dust.noGravity = !Main.rand.NextBool(3); + dust.scale = Main.rand.NextFloat(0.45f, 0.6f); + dust.color = Color.Gold; + dust.noLightEmittence = true; + */ + if (Projectile.timeLeft > 30) { - Projectile.scale -= 0.01f; - Projectile.alpha += 15; - if (Projectile.alpha >= 250) + for (int i = 0; i < 2; i++) { - Projectile.alpha = 255; - Projectile.localAI[0] = 1f; - } - } - else if (Projectile.localAI[0] == 1f) - { - Projectile.scale += 0.01f; - Projectile.alpha -= 15; - if (Projectile.alpha <= 0) - { - Projectile.alpha = 0; - Projectile.localAI[0] = 0f; - } - } - Projectile.localAI[1] += 1f; - if (Projectile.localAI[1] == 3f) - { - for (int l = 0; l < 12; l++) - { - Vector2 dustRotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - dustRotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - dustRotate = dustRotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int dusty = Dust.NewDust(Projectile.Center, 0, 0, DustID.CopperCoin, 0f, 0f, 160, default, 1f); - Main.dust[dusty].scale = 1.1f; - Main.dust[dusty].noGravity = true; - Main.dust[dusty].position = Projectile.Center + dustRotate; - Main.dust[dusty].velocity = Projectile.velocity * 0.1f; - Main.dust[dusty].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[dusty].position) * 1.25f; + Vector2 offset = (MathHelper.TwoPi * i / 2f).ToRotationVector2().RotatedBy(Projectile.timeLeft * 0.1f) * 35 * velLerp; + Vector2 dustVel = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.1f) * Main.rand.NextFloat(5.5f, 6.5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, 278, dustVel); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.4f, 0.5f); + dust.color = Color.Gold; + dust.noLightEmittence = true; } } } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.velocity *= 0.25f; + float minMult = 0.5f; + int hitsToMinMult = 3; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + for (int g = 0; g < 4; g++) + { + for (int i = 0; i < 2; i++) + { + Vector2 offset = (MathHelper.TwoPi * i / 2f).ToRotationVector2().RotatedBy(Projectile.timeLeft * 0.1f) * 35 * velLerp; + Vector2 dustVel = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, ModContent.DustType(), dustVel.RotatedByRandom(0.3f) * Main.rand.NextFloat(5.5f, 9.5f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.2f, 1.5f); + dust.color = Color.Gold; + dust.noLightEmittence = true; + } + } } - + public override bool OnTileCollide(Vector2 oldVelocity) + { + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 10 + 65 * velLerp, targetHitbox); public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); + Asset tex = ModContent.Request(Texture); + Color drawColor = Color.Gold; + float fade = Utils.GetLerpValue(0, 90, Projectile.timeLeft, true); + + for (int i = 0; i < 2; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 2f).ToRotationVector2().RotatedBy(Projectile.timeLeft * 0.1f) * 45 * velLerp; + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + drawOffset, null, drawColor with { A = 0 } * 0.6f * (float)Math.Pow(fade, 3), Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + } + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, Color.White * fade, Projectile.rotation, tex.Size() * 0.5f, new Vector2(1 - 0.3f * velLerp, 1 + 0.8f * velLerp) * Projectile.scale, SpriteEffects.None); return false; } } diff --git a/Projectiles/Magic/LuxorsGiftMagic.png b/Projectiles/Magic/LuxorsGiftMagic.png index e3e09a3ae8..90f9061be1 100644 Binary files a/Projectiles/Magic/LuxorsGiftMagic.png and b/Projectiles/Magic/LuxorsGiftMagic.png differ diff --git a/Projectiles/Melee/LuxorsGiftMelee.cs b/Projectiles/Melee/LuxorsGiftMelee.cs index 83d423e61e..1d102d26d6 100644 --- a/Projectiles/Melee/LuxorsGiftMelee.cs +++ b/Projectiles/Melee/LuxorsGiftMelee.cs @@ -1,5 +1,9 @@ -using CalamityMod.Dusts; +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -15,100 +19,82 @@ namespace CalamityMod.Projectiles.Melee ProjectileID.Sets.TrailCacheLength[Type] = 10; ProjectileID.Sets.TrailingMode[Type] = 1; } - public override void SetDefaults() { - Projectile.width = 20; - Projectile.height = 20; + Projectile.width = 30; + Projectile.height = 38; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; - Projectile.penetrate = 3; - Projectile.alpha = 255; - Projectile.timeLeft = 300; + Projectile.penetrate = -1; // Works like 2 + Projectile.timeLeft = 180; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.localNPCHitCooldown = -1; + Projectile.extraUpdates = 2; } - public override void AI() { - if (Projectile.localAI[0] == 0f) + Lighting.AddLight(Projectile.Center, Color.Red.ToVector3() * 0.35f); + Projectile.scale = (Projectile.ai[0] == 5 ? 0.5f : 0.75f); + Projectile.velocity *= 0.973f; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (Projectile.ai[0] == 5) { - Projectile.scale -= 0.01f; - Projectile.alpha += 15; - if (Projectile.alpha >= 250) + if (Projectile.timeLeft % 9 == 0 && Projectile.timeLeft > 30) { - Projectile.alpha = 255; - Projectile.localAI[0] = 1f; + Vector2 dustVel = -(Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.5f) * Main.rand.NextFloat(0.8f, 1.3f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5), ModContent.DustType(), dustVel * Main.rand.NextFloat(0.5f, 1.2f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.45f, 0.6f); + dust.color = Color.Red; + dust.alpha = 120; + dust.noLightEmittence = true; } } - else if (Projectile.localAI[0] == 1f) + else if (Projectile.timeLeft % 4 == 0 && Projectile.timeLeft > 30) { - Projectile.scale += 0.01f; - Projectile.alpha -= 15; - if (Projectile.alpha <= 0) - { - Projectile.alpha = 0; - Projectile.localAI[0] = 0f; - } + Vector2 dustVel = -(Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.5f) * Main.rand.NextFloat(0.8f, 1.3f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), ModContent.DustType(), dustVel * Main.rand.NextFloat(0.5f, 1.2f)); + dust.noGravity = !Main.rand.NextBool(3); + dust.scale = Main.rand.NextFloat(0.45f, 0.6f); + dust.color = Color.Red; + dust.noLightEmittence = true; } - Projectile.localAI[1] += 1f; - if (Projectile.localAI[1] == 3f) + if (Projectile.timeLeft > 90 && Projectile.timeLeft < 177 && Projectile.timeLeft % 2 == 0 && Projectile.ai[0] == 0) { - for (int l = 0; l < 12; l++) - { - Vector2 dustRotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - dustRotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - dustRotate = dustRotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int spawnDust = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.Brimstone, 0f, 0f, 160, default, 1f); - Main.dust[spawnDust].scale = 1.1f; - Main.dust[spawnDust].noGravity = true; - Main.dust[spawnDust].position = Projectile.Center + dustRotate; - Main.dust[spawnDust].velocity = Projectile.velocity * 0.1f; - Main.dust[spawnDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[spawnDust].position) * 1.25f; - } + Particle spark = new GlowSparkParticle(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 2, -Projectile.velocity.SafeNormalize(Vector2.UnitX) * 2, false, 14, 0.02f, Color.Red * 0.45f, new Vector2(1.4f, 1f), true, false, 0.6f); + GeneralParticleHandler.SpawnParticle(spark); } } - - public override Color? GetAlpha(Color lightColor) + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - return new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - return new Color(255, 255, 255, 100); + float minMult = 0.5f; + int hitsToMinMult = 3; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + if (Projectile.numHits >= 1 && Projectile.timeLeft > 70) + Projectile.timeLeft = 70; } - public override bool OnTileCollide(Vector2 oldVelocity) { - SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - for (int l = 0; l < 12; l++) - { - Vector2 dustRotate = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - dustRotate += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - dustRotate = dustRotate.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int spawnDust = Dust.NewDust(Projectile.Center, 0, 0, (int)CalamityDusts.Brimstone, 0f, 0f, 160, default, 1f); - Main.dust[spawnDust].scale = 1.1f; - Main.dust[spawnDust].noGravity = true; - Main.dust[spawnDust].position = Projectile.Center + dustRotate; - Main.dust[spawnDust].velocity = Projectile.velocity * 0.1f; - Main.dust[spawnDust].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[spawnDust].position) * 1.25f; - } - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; - } - if (Projectile.velocity.Y != oldVelocity.Y) - { - Projectile.velocity.Y = -oldVelocity.Y; - } + Projectile.velocity = oldVelocity * 0.85f; return false; } - + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => (Projectile.ai[0] == 5 || Projectile.numHits >= 2) ? false : CalamityUtils.CircularHitboxCollision(Projectile.Center, 20, targetHitbox); public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); + Asset tex = ModContent.Request(Texture); + Color drawColor = Color.Red; + float fade = Utils.GetLerpValue(0, 90, Projectile.timeLeft, true); + + + for (int i = 0; i < 8; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 8f).ToRotationVector2() * 2f; + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + drawOffset, null, drawColor with { A = 0 } * 0.4f * (float)Math.Pow(fade, 3), Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + } + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, Color.White * fade, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + //CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); return false; } } diff --git a/Projectiles/Melee/LuxorsGiftMelee.png b/Projectiles/Melee/LuxorsGiftMelee.png index 7fc8375ae3..d773032b82 100644 Binary files a/Projectiles/Melee/LuxorsGiftMelee.png and b/Projectiles/Melee/LuxorsGiftMelee.png differ diff --git a/Projectiles/Ranged/LuxorsGiftRanged.cs b/Projectiles/Ranged/LuxorsGiftRanged.cs index 07ef96b9fc..1c71157927 100644 --- a/Projectiles/Ranged/LuxorsGiftRanged.cs +++ b/Projectiles/Ranged/LuxorsGiftRanged.cs @@ -1,4 +1,8 @@ -using Microsoft.Xna.Framework; +using System; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -17,87 +21,79 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - Projectile.width = 14; - Projectile.height = 14; + Projectile.width = 38; + Projectile.height = 38; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; - Projectile.alpha = 255; - Projectile.timeLeft = 180; + Projectile.timeLeft = 300; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.extraUpdates = 5; } - - public override Color? GetAlpha(Color lightColor) - { - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - return new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - return new Color(255, 255, 255, 100); - } - public override void AI() { - if (Projectile.localAI[0] == 0f) - { - Projectile.scale -= 0.01f; - Projectile.alpha += 15; - if (Projectile.alpha >= 250) - { - Projectile.alpha = 255; - Projectile.localAI[0] = 1f; - } - } - else if (Projectile.localAI[0] == 1f) - { - Projectile.scale += 0.01f; - Projectile.alpha -= 15; - if (Projectile.alpha <= 0) - { - Projectile.alpha = 0; - Projectile.localAI[0] = 0f; - } - } + Lighting.AddLight(Projectile.Center, Color.Cyan.ToVector3() * 0.35f); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Projectile.localAI[1] += 1f; - if (Projectile.localAI[1] == 3f) + if (Projectile.timeLeft == 300) + Projectile.velocity *= 0.5f; + if (Projectile.timeLeft > 30) { - for (int l = 0; l < 12; l++) + for (int i = 0; i < 2; i++) { - Vector2 offset = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - offset += -Vector2.UnitY.RotatedBy((double)(l * MathHelper.Pi / 6f), default) * new Vector2(8f, 16f); - offset = offset.RotatedBy((double)(Projectile.rotation - MathHelper.PiOver2), default); - int electric = Dust.NewDust(Projectile.Center, 0, 0, DustID.IceTorch, 0f, 0f, 160, default, 1f); - Main.dust[electric].scale = 1.1f; - Main.dust[electric].noGravity = true; - Main.dust[electric].position = Projectile.Center + offset; - Main.dust[electric].velocity = Projectile.velocity * 0.1f; - Main.dust[electric].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[electric].position) * 1.25f; + Vector2 dustPos = Projectile.Center + Projectile.velocity.RotatedBy(MathHelper.PiOver2) * (i == 0 ? -3 : 3); + Vector2 dustVel = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.2f) * Main.rand.NextFloat(2.5f, 8.5f); + Dust dust = Dust.NewDustPerfect(dustPos + Main.rand.NextVector2Circular(2, 2), Main.rand.NextBool() ? 278 : ModContent.DustType(), dustVel * Main.rand.NextFloat(0.5f, 1.2f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.3f, 0.4f); + dust.color = Color.Cyan; + dust.noLightEmittence = true; } } } - - public override void OnKill(int timeLeft) + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Projectile.ExpandHitboxBy(16); - Projectile.maxPenetrate = Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.Damage(); - SoundEngine.PlaySound(SoundID.Item92, Projectile.position); - int dustAmt = Main.rand.Next(10, 20); - for (int d = 0; d < dustAmt; d++) + float minMult = 0.5f; + int hitsToMinMult = 3; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + + for (int i = 0; i < 12; i++) { - int electric = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, DustID.IceTorch, 0f, 0f, 100, default, 2f); - Main.dust[electric].velocity *= 2f; - Main.dust[electric].noGravity = true; + Vector2 dustVel = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.2f) * Main.rand.NextFloat(2.5f, 8.5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(11, 11), Main.rand.NextBool() ? 278 : ModContent.DustType(), dustVel * Main.rand.NextFloat(0.3f, 1.7f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.8f, 1.1f); + dust.color = Color.Cyan; + dust.noLightEmittence = true; } } - + public override bool OnTileCollide(Vector2 oldVelocity) + { + for (int i = 0; i < 12; i++) + { + Vector2 dustVel = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.2f) * Main.rand.NextFloat(2.5f, 8.5f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(11, 11), Main.rand.NextBool() ? 278 : ModContent.DustType(), dustVel * Main.rand.NextFloat(0.3f, 1.7f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.8f, 1.1f); + dust.color = Color.Cyan; + dust.noLightEmittence = true; + } + return true; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 20, targetHitbox); public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); + Asset tex = ModContent.Request(Texture); + Color drawColor = Color.Cyan; + float fade = Utils.GetLerpValue(0, 90, Projectile.timeLeft, true); + + for (int i = 0; i < 8; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 8f).ToRotationVector2() * 2f; + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + drawOffset, null, drawColor with { A = 0 } * 0.4f * (float)Math.Pow(fade, 3), Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + } + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, Color.White * fade, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); return false; } } diff --git a/Projectiles/Ranged/LuxorsGiftRanged.png b/Projectiles/Ranged/LuxorsGiftRanged.png index 21c519768f..4537405b02 100644 Binary files a/Projectiles/Ranged/LuxorsGiftRanged.png and b/Projectiles/Ranged/LuxorsGiftRanged.png differ diff --git a/Projectiles/Rogue/LuxorsGiftRogue.cs b/Projectiles/Rogue/LuxorsGiftRogue.cs index 2b0e580ad5..8d06bbd973 100644 --- a/Projectiles/Rogue/LuxorsGiftRogue.cs +++ b/Projectiles/Rogue/LuxorsGiftRogue.cs @@ -1,5 +1,8 @@ using System; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,95 +20,92 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - Projectile.width = 18; - Projectile.height = 18; + Projectile.width = 34; + Projectile.height = 48; Projectile.friendly = true; - Projectile.penetrate = 4; - Projectile.aiStyle = ProjAIStyleID.ThrownProjectile; - Projectile.alpha = 255; - Projectile.timeLeft = 300; - AIType = ProjectileID.ThrowingKnife; + Projectile.penetrate = 3; + Projectile.timeLeft = 600; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; - Projectile.DamageType = RogueDamageClass.Instance; + Projectile.localNPCHitCooldown = -1; + Projectile.extraUpdates = 3; } - public override void AI() { + Lighting.AddLight(Projectile.Center, Color.Magenta.ToVector3() * 0.35f); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - if (Projectile.localAI[0] == 0f) + if (Projectile.numHits == 0) { - Projectile.scale -= 0.01f; - Projectile.alpha += 15; - if (Projectile.alpha >= 250) - { - Projectile.alpha = 255; - Projectile.localAI[0] = 1f; - } - } - else if (Projectile.localAI[0] == 1f) - { - Projectile.scale += 0.01f; - Projectile.alpha -= 15; - if (Projectile.alpha <= 0) - { - Projectile.alpha = 0; - Projectile.localAI[0] = 0f; - } - } - Projectile.localAI[1] += 1f; - if (Projectile.localAI[1] == 3f) - { - for (int l = 0; l < 12; l++) - { - Vector2 rotation = Vector2.UnitX * (float)-(float)Projectile.width / 2f; - rotation += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); - rotation = rotation.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); - int dusty = Dust.NewDust(Projectile.Center, 0, 0, DustID.ShadowbeamStaff, 0f, 0f, 160, default, 1f); - Main.dust[dusty].scale = 1.1f; - Main.dust[dusty].noGravity = true; - Main.dust[dusty].position = Projectile.Center + rotation; - Main.dust[dusty].velocity = Projectile.velocity * 0.1f; - Main.dust[dusty].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[dusty].position) * 1.25f; - } - } - } - - public override Color? GetAlpha(Color lightColor) - { - if (Projectile.timeLeft < 85) - { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - return new Color((int)b2, (int)b2, (int)b2, (int)a2); - } - return new Color(255, 255, 255, 100); - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.penetrate--; - if (Projectile.penetrate <= 0) - { - Projectile.Kill(); + Projectile.velocity.Y += 0.04f; + if (Projectile.velocity.Y > 0) + Projectile.velocity.X *= 0.99f; } else { - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; - } - if (Projectile.velocity.Y != oldVelocity.Y) - { - Projectile.velocity.Y = -oldVelocity.Y; - } + Projectile.velocity.Y += 0.06f; + if (Projectile.velocity.Y > 0) + Projectile.velocity.X *= 0.985f; } + if (Projectile.timeLeft > 60) + { + Vector2 dustVel = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.05f) * Main.rand.NextFloat(0.1f, 0.3f); + Dust dust = Dust.NewDustPerfect(Projectile.Center, 278, dustVel); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.4f, 0.5f); + dust.color = Color.Magenta; + dust.noLightEmittence = true; + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float minMult = 0.4f; + int hitsToMinMult = 3; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + + Projectile.velocity = Utils.DirectionTo(target.Center, Projectile.Center).RotatedByRandom(0.2f) * 7; + Projectile.velocity.X *= 0.2f; + Projectile.velocity.Y *= 1.2f; + + for (int i = 0; i < 8; i++) + { + Dust c = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + c.velocity = (MathHelper.TwoPi * i / 8f).ToRotationVector2().RotatedBy(MathHelper.PiOver4) * 4.5f * (i % 2 == 0 ? 0.78f : 1f); + c.scale = Main.rand.NextFloat(0.6f, 0.7f) * (i % 2 == 0 ? 2.2f : 1.8f); + c.noGravity = true; + c.color = Color.Magenta; + c.noLightEmittence = true; + } + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (Projectile.numHits == 0) + Projectile.numHits = 1; + if (Projectile.velocity.X != oldVelocity.X) + { + Projectile.velocity.X = -oldVelocity.X; + } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + Projectile.velocity *= 0.92f; + for (int i = 0; i < Main.maxNPCs; i++) + Projectile.localNPCImmunity[i] = 0; return false; } - + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 30, targetHitbox); public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); + Asset tex = ModContent.Request(Texture); + Color drawColor = Color.Magenta; + float fade = Utils.GetLerpValue(0, 90, Projectile.timeLeft, true); + + for (int i = 0; i < 8; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 8f).ToRotationVector2() * 2f; + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + drawOffset, null, drawColor with { A = 0 } * 0.4f * (float)Math.Pow(fade, 3), Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + } + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, Color.White * fade, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); return false; } } diff --git a/Projectiles/Rogue/LuxorsGiftRogue.png b/Projectiles/Rogue/LuxorsGiftRogue.png index 2ffc26c9c7..c64245ed65 100644 Binary files a/Projectiles/Rogue/LuxorsGiftRogue.png and b/Projectiles/Rogue/LuxorsGiftRogue.png differ diff --git a/Projectiles/Summon/LuxorsGiftSummon.cs b/Projectiles/Summon/LuxorsGiftSummon.cs index 3ad6878f52..cf487f853e 100644 --- a/Projectiles/Summon/LuxorsGiftSummon.cs +++ b/Projectiles/Summon/LuxorsGiftSummon.cs @@ -1,5 +1,10 @@ -using CalamityMod.CalPlayer; +using System; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,10 +15,10 @@ namespace CalamityMod.Projectiles.Summon { public new string LocalizationCategory => "Projectiles.Summon"; private int dust = 3; - + public NPC targeted; + public int attackTime = 0; public override void SetStaticDefaults() { - ProjectileID.Sets.MinionTargettingFeature[Type] = true; ProjectileID.Sets.TrailCacheLength[Type] = 10; ProjectileID.Sets.TrailingMode[Type] = 1; } @@ -21,96 +26,85 @@ namespace CalamityMod.Projectiles.Summon public override void SetDefaults() { Projectile.width = 14; - Projectile.height = 14; - Projectile.netImportant = true; + Projectile.height = 46; Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.minionSlots = 0f; - Projectile.timeLeft = 180000; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.timeLeft *= 5; - Projectile.minion = true; + Projectile.penetrate = -1; // 3 + Projectile.timeLeft = 600; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - Projectile.DamageType = DamageClass.Summon; + Projectile.extraUpdates = 2; + Projectile.tileCollide = false; } - public override void AI() { - Player player = Main.player[Projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - if (dust > 0) - { - int dustAmt = 36; - for (int i = 0; i < dustAmt; i++) - { - Vector2 rotate = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.75f; - rotate = rotate.RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + Projectile.Center; - Vector2 faceDirection = rotate - Projectile.Center; - int dust = Dust.NewDust(rotate + faceDirection, 0, 0, DustID.TerraBlade, faceDirection.X * 1.75f, faceDirection.Y * 1.75f, 100, default, 1.1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity = faceDirection; - } - dust--; - } - if (Projectile.localAI[0] == 0f) - { - Projectile.scale -= 0.01f; - Projectile.alpha += 15; - if (Projectile.alpha >= 250) - { - Projectile.alpha = 255; - Projectile.localAI[0] = 1f; - } - } - else if (Projectile.localAI[0] == 1f) - { - Projectile.scale += 0.01f; - Projectile.alpha -= 15; - if (Projectile.alpha <= 0) - { - Projectile.alpha = 0; - Projectile.localAI[0] = 0f; - } - } - - bool isMinion = Projectile.type == ModContent.ProjectileType(); - if (isMinion) - { - if (!modPlayer.luxorsGift || player.dead) - { - Projectile.Kill(); - } - } - - Projectile.ChargingMinionAI(700f, 1000f, 2200f, 150f, 0, 40f, 9f, 4f, new Vector2(0f, -60f), 40f, 9f, true, true); - + Lighting.AddLight(Projectile.Center, Color.Lime.ToVector3() * 0.35f); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - } + if (targeted == null || !targeted.active || targeted.life <= 0) + targeted = Projectile.Center.ClosestNPCAt(500); + if (targeted != null && attackTime == 0) + { + CalamityUtils.HomeInOnSelectedNPC(Projectile, targeted, true, 0.8f, 12, 0.93f, 0.99f); + } + if (attackTime > 0) + { + attackTime--; + Projectile.velocity = Projectile.velocity.RotatedBy(0.09f * (Projectile.numHits % 2 == 0 ? -1 : 1)); + if (Projectile.velocity.Length() < 12) + Projectile.velocity *= 1.025f; + } + if (Projectile.timeLeft % 2 == 0) + { + bool sparkly = Main.rand.NextBool(3); + Vector2 dustVel = -(Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.5f) * Main.rand.NextFloat(0.8f, 1.3f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), sparkly ? 278 : ModContent.DustType(), dustVel * Main.rand.NextFloat(0.5f, 1.2f)); + dust.noGravity = !sparkly; + dust.scale = Main.rand.NextFloat(0.45f, 0.6f) * (sparkly ? 1.6f : 1); + dust.color = Color.Lime; + dust.noLightEmittence = true; + dust.velocity *= (sparkly ? 1 : 8); + } + + Particle spark = new CustomSpark(Projectile.Center - Projectile.velocity * 0.5f, -Projectile.velocity * 0.01f, "CalamityMod/Particles/BloomCircle", false, 9, 0.18f, Color.Lime * 0.7f, new Vector2(0.9f, 1.2f), true, false, 0.4f); + GeneralParticleHandler.SpawnParticle(spark); + } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - modifiers.DisableCrit(); - if (!Collision.CanHit(Projectile, Main.player[Projectile.owner])) - modifiers.SourceDamage *= 0.75f; // Minion deals 75% damage if it doesn't have line of sight with its owner - } + float minMult = 0.5f; + int hitsToMinMult = 3; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; - public override Color? GetAlpha(Color lightColor) - { - if (Projectile.timeLeft < 85) + attackTime = 45; + + if (Projectile.numHits >= 2) { - byte b2 = (byte)(Projectile.timeLeft * 3); - byte a2 = (byte)(100f * ((float)b2 / 255f)); - return new Color((int)b2, (int)b2, (int)b2, (int)a2); + for (int i = 0; i < 12; i++) + { + Vector2 dustVel = -(Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.8f) * Main.rand.NextFloat(6f, 14f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), ModContent.DustType(), dustVel); + dust.noGravity = Main.rand.NextBool(); + dust.scale = Main.rand.NextFloat(0.65f, 1.2f); + dust.color = Color.Lime; + dust.noLightEmittence = true; + } } - return new Color(255, 255, 255, 100); } - + public override bool? CanHitNPC(NPC target) => (targeted != null && target == targeted && attackTime == 0) ? null : false; + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 8, targetHitbox); public override bool PreDraw(ref Color lightColor) { - var dye = Main.player[Projectile.owner]?.cMinion ?? 0; - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2, armorShaderToUse: dye); + Asset tex = ModContent.Request(Texture); + Color drawColor = Color.Lime; + float fade = Utils.GetLerpValue(0, 90, Projectile.timeLeft, true); + + + for (int i = 0; i < 8; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 8f).ToRotationVector2() * 2f; + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + drawOffset, null, drawColor with { A = 0 } * 0.4f * (float)Math.Pow(fade, 3), Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + } + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, Color.White * fade, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); return false; } } diff --git a/Projectiles/Summon/LuxorsGiftSummon.png b/Projectiles/Summon/LuxorsGiftSummon.png index 0c2d362ed3..8a4c550a80 100644 Binary files a/Projectiles/Summon/LuxorsGiftSummon.png and b/Projectiles/Summon/LuxorsGiftSummon.png differ diff --git a/Projectiles/Typeless/Luxor.cs b/Projectiles/Typeless/Luxor.cs new file mode 100644 index 0000000000..7c20ddac95 --- /dev/null +++ b/Projectiles/Typeless/Luxor.cs @@ -0,0 +1,251 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class Luxor : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer moddedOwner => Owner.Calamity(); + public Color usedColor = Color.White; + public DamageClass lastDamageClass = null; + public ref float time => ref Projectile.ai[0]; + public ref float attackTimer => ref Projectile.ai[1]; + public ref float idleTimer => ref Projectile.localAI[0]; + public int classType = 0; // 0 = Classless, 1 = Melee, 2 = Ranged, 3 = Mage, 4 = Summoner, 5 = Rogue + public Vector2 tipPosition => Projectile.Center + (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * 15; + + public float fxFade = 0; // The glow visuals multiplier + public float postFireBoost = 0; // The glow increases right when you fire, then quickly fades + public float followSpeed = 6; // The speed Luxor follows you, lower is faster + public bool rogueChain = true; // Used for rogue's double projectile shot + public override void SetDefaults() + { + Projectile.width = 114; + Projectile.height = 38; + Projectile.ignoreWater = true; + Projectile.timeLeft = 300; + Projectile.tileCollide = false; + Projectile.friendly = true; + Projectile.penetrate = -1; + } + + public override void AI() + { + Color classColor = Color.White; + DamageClass itemClass = Owner.HeldItem.DamageType; + if (itemClass == null) + { + Projectile.Kill(); + return; + } + else if (itemClass.CountsAsClass()) + { classColor = Color.Red; classType = 1; } + else if (itemClass.CountsAsClass()) + { classColor = Color.Cyan; classType = 2; } + else if (itemClass.CountsAsClass()) + { classColor = Color.Gold; classType = 3; } + else if (itemClass.CountsAsClass()) + { classColor = Color.Lime; classType = 4; } + else if (itemClass.CountsAsClass()) + { classColor = Color.Magenta; classType = 5; } + else + { classColor = Color.Gray; classType = 0; }; + + if (time == 0 || itemClass != lastDamageClass) + { + Projectile.netUpdate = true; + attackTimer = 60; // 60 frame attack delay on spawn or swapping class weapons + } + lastDamageClass = itemClass; + + float rate = Main.GlobalTimeWrappedHourly * 7; + List eColors = new List() + { + Color.Lerp(classColor, Color.White, 0.15f), + Color.Lerp(classColor, Color.Black, 0.15f) + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + usedColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + Projectile.velocity = Utils.DirectionTo(Projectile.Center, Owner.Calamity().mouseWorld); + + Vector2 destination = Vector2.Lerp(Owner.Center - Projectile.velocity * (70 + 100 * Utils.GetLerpValue(0, 110, attackTimer, true)), Owner.Center + Vector2.UnitY * -40, Utils.GetLerpValue(280, 300, idleTimer, true)); + Projectile.velocity = (destination - Projectile.Center) / followSpeed; + + Projectile.rotation = Utils.DirectionTo(Projectile.Center, Owner.Calamity().mouseWorld).ToRotation() + MathHelper.PiOver2; + + fxFade = (float)Math.Pow(Utils.GetLerpValue(30, 0, attackTimer, true), 3) + postFireBoost; + + if (idleTimer >= 280) + { + if (moddedOwner.luxorHit) + { + if (idleTimer > 320) + idleTimer = 320; + idleTimer -= 1; + } + else + { + fxFade = 1; + attackTimer = 40; + } + } + else + { + + } + + if (attackTimer == 0 && moddedOwner.luxorHit) + { + int attackSpeed = 0; + int attackDamage = 0; + int projType = 0; + switch (classType) + { + case 0: attackSpeed = LuxorsGift.classlessAttackSpeed; attackDamage = LuxorsGift.classlessDamage; projType = ModContent.ProjectileType(); break; + case 1: attackSpeed = LuxorsGift.meleeAttackSpeed; attackDamage = LuxorsGift.meleeDamage; projType = ModContent.ProjectileType(); break; + case 2: attackSpeed = LuxorsGift.rangedAttackSpeed; attackDamage = LuxorsGift.rangedDamage; projType = ModContent.ProjectileType(); break; + case 3: attackSpeed = LuxorsGift.magicAttackSpeed; attackDamage = LuxorsGift.magicDamage; projType = ModContent.ProjectileType(); break; + case 4: attackSpeed = LuxorsGift.summonerAttackSpeed; attackDamage = LuxorsGift.summonerDamage; projType = ModContent.ProjectileType(); break; + case 5: attackSpeed = LuxorsGift.rogueAttackSpeed; attackDamage = LuxorsGift.rogueDamage; projType = ModContent.ProjectileType(); break; + } + float powerMult = Utils.GetLerpValue(-120, 140, attackSpeed, true); // An intensity multiplier based on the fire rate of the mode + if (Main.zenithWorld) // Just like old times + { + attackSpeed = 0; + attackDamage = Math.Max(1, (int)(Owner.HeldItem.damage * Utils.Remap(Owner.HeldItem.useAnimation, 3, 120, 0.025f, 1f, false))); + } + + for (int i = 0; i < (int)(20 * powerMult); i++) // Firing dust + { + Vector2 dustVel = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2().RotatedByRandom(0.5f) * 12 * powerMult; + Dust dust = Dust.NewDustPerfect(tipPosition, ModContent.DustType(), dustVel * Main.rand.NextFloat(0.5f, 1.2f)); + dust.noGravity = !Main.rand.NextBool(3); + dust.scale = Main.rand.NextFloat(0.75f, 1.4f) * powerMult; + dust.color = usedColor; + dust.noLightEmittence = true; + } + if (classType == 1) // Melee shotgun + { + for (int i = -1; i <= 1; i++) + { + Projectile proj = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, Utils.DirectionTo(tipPosition, Owner.Calamity().mouseWorld).RotatedBy(-0.12f * i * Main.rand.NextFloat(0.7f, 1f)) * (12 - Main.rand.NextFloat(0f, 0.6f) - Math.Abs(i)), projType, (int)(Owner.GetDamage(itemClass).ApplyTo(attackDamage)), 0f, Owner.whoAmI); + proj.ArmorPenetration = LuxorsGift.luxArmorPen; + } + for (int i = 0; i < 5; i++) // These are visual + { + Projectile proj = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, Utils.DirectionTo(tipPosition, Owner.Calamity().mouseWorld).RotatedByRandom(0.4f) * (12 - Main.rand.NextFloat(2f, 5f)), projType, (int)(Owner.GetDamage(itemClass).ApplyTo(attackDamage)), 0f, Owner.whoAmI, 5); + proj.timeLeft = 95; + } + } + else // Everything else + { + Projectile proj = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, Utils.DirectionTo(tipPosition, Owner.Calamity().mouseWorld) * 12, projType, (int)(Owner.GetDamage(itemClass).ApplyTo(attackDamage)), 0f, Owner.whoAmI); + proj.ArmorPenetration = LuxorsGift.luxArmorPen; + if (classType == 5) // Rogue has gravity so velocity is adjusted a bit + proj.velocity.Y -= 1.5f; + } + + SoundStyle blam = new("CalamityMod/Sounds/Item/GunShotSmall"); + SoundEngine.PlaySound(blam with { Volume = 0.35f, Pitch = Main.rand.NextFloat(0.6f, 0.8f) }, tipPosition); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact with { Volume = 0.7f, Pitch = 0.2f }, tipPosition); + + if (classType == 5 && rogueChain) + { + rogueChain = false; + attackTimer = attackSpeed / 3; + } + else + { + attackTimer = attackSpeed; + moddedOwner.luxorHit = false; + if (!CalamityClientConfig.Instance.Photosensitivity) + postFireBoost = 1.7f; + idleTimer = 0; + rogueChain = true; + } + Projectile.netUpdate = true; + } + if (attackTimer > 0) + attackTimer--; + if (postFireBoost > 0) // Quickly fade out the increased poost fire visuals + postFireBoost -= 0.2f; + + if (time % 2 == 0 && false) + { + Vector2 dustVel = new Vector2(10, 10).RotatedByRandom(100); + Dust dust = Dust.NewDustPerfect(Owner.Center + dustVel, ModContent.DustType(), dustVel * Main.rand.NextFloat(0.1f, 0.4f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.5f, 0.7f); + dust.color = usedColor; + dust.noLightEmittence = true; + } + + float idleFade = Utils.GetLerpValue(280, 300, idleTimer, true); + Lighting.AddLight(tipPosition, Color.Lerp(usedColor, Color.Lerp(usedColor, Color.White, 0.5f), idleFade).ToVector3() * (0.5f * MathHelper.Lerp(fxFade, 1, 0.55f) + 0.35f * idleFade)); + + if (moddedOwner.luxorsGift) + Projectile.timeLeft++; + else + Projectile.Kill(); + if (Owner.dead) + Projectile.Kill(); + + time++; + if (!moddedOwner.luxorHit) + idleTimer++; + } + public override bool PreDraw(ref Color lightColor) + { + Asset tex = ModContent.Request(Texture); + Texture2D bTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Texture2D cTexture = ModContent.Request("CalamityMod/Particles/Light").Value; + float idleFade = (float)Math.Pow(Utils.GetLerpValue(280, 300, idleTimer, true), 5); + Color drawColor = usedColor; + Color bodyColor = Color.Lerp(lightColor, Color.Gold with { A = 0 }, idleFade); + float drawMult = Math.Max(idleFade, fxFade); + + if (idleFade == 0) + { + for (int i = 0; i < 18; i++) // Backglow + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 18f).ToRotationVector2() * 6 * drawMult; + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + drawOffset, null, drawColor with { A = 0 } * 0.2f * drawMult, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + } + } + // Main body + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, bodyColor * (1 - idleFade), Projectile.rotation, tex.Size() * 0.5f, new Vector2(1 - 0.85f * idleFade, 1f) * Projectile.scale, SpriteEffects.None); + for (int i = 0; i < 4; i++) // Glow orb + { + Main.EntitySpriteDraw(bTexture, Vector2.Lerp(tipPosition, Projectile.Center, idleFade) - Main.screenPosition, null, drawColor with { A = 0 } * 0.35f * drawMult, time * 0.13f * (i + 1), bTexture.Size() * 0.5f, new Vector2(1 + i * 0.15f, i - 0.3f * i) * Projectile.scale * MathHelper.Lerp(0.33f, 0.22f, idleFade) * drawMult, SpriteEffects.None); + } + // Glow orb center + Main.EntitySpriteDraw(cTexture, Vector2.Lerp(tipPosition, Projectile.Center, idleFade) - Main.screenPosition, null, Color.White with { A = 0 } * 0.75f * drawMult, Projectile.rotation, cTexture.Size() * 0.5f, Projectile.scale * MathHelper.Lerp(0.4f, 0.3f, idleFade) * drawMult, SpriteEffects.None); + return false; + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Typeless/Luxor.png b/Projectiles/Typeless/Luxor.png new file mode 100644 index 0000000000..6962d76a0d Binary files /dev/null and b/Projectiles/Typeless/Luxor.png differ diff --git a/Projectiles/Typeless/LuxorsGiftClassless.cs b/Projectiles/Typeless/LuxorsGiftClassless.cs new file mode 100644 index 0000000000..79ba8f85d7 --- /dev/null +++ b/Projectiles/Typeless/LuxorsGiftClassless.cs @@ -0,0 +1,94 @@ +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class LuxorsGiftClassless : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 10; + ProjectileID.Sets.TrailingMode[Type] = 1; + } + public override void SetDefaults() + { + Projectile.width = 30; + Projectile.height = 38; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.timeLeft = 300; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.extraUpdates = 6; + Projectile.tileCollide = false; + } + public override void AI() + { + Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.35f); + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (Projectile.timeLeft < 294) + { + Particle spark = new GlowSparkParticle(Projectile.Center - Projectile.velocity, -Projectile.velocity * 0.3f, false, 18, 0.03f * (1 + Utils.GetLerpValue(270, 300, Projectile.timeLeft, true)), Color.Gray * 0.45f, new Vector2(1.1f * (1 + Utils.GetLerpValue(270, 300, Projectile.timeLeft, true)), 1.3f), true, false, 0.3f); + GeneralParticleHandler.SpawnParticle(spark); + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float minMult = 0.1f; + int hitsToMinMult = 7; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + + for (int i = 0; i < Math.Max(6 - Projectile.numHits, 1); i++) + { + Particle spark = new GlowSparkParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.5f), false, 8, 0.02f, Color.White * 0.75f, new Vector2(0.8f, 1.3f), true, false, 1f); + GeneralParticleHandler.SpawnParticle(spark); + + for (int y = 0; y < 2; y++) + { + SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.8f, 1.3f), false, 35, 0.5f, Color.White); + GeneralParticleHandler.SpawnParticle(spark2); + } + } + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (Projectile.velocity.X != oldVelocity.X) + { + Projectile.velocity.X = -oldVelocity.X; + } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 20, targetHitbox); + public override bool PreDraw(ref Color lightColor) + { + Asset tex = ModContent.Request(Texture); + Color drawColor = Color.Gray; + float fade = Utils.GetLerpValue(0, 90, Projectile.timeLeft, true); + + + for (int i = 0; i < 8; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 8f).ToRotationVector2() * 2f; + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition + drawOffset, null, drawColor with { A = 0 } * 0.4f * (float)Math.Pow(fade, 3), Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + } + Main.EntitySpriteDraw(tex.Value, Projectile.Center - Main.screenPosition, null, Color.White * fade, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + //CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); + return false; + } + } +} diff --git a/Projectiles/Typeless/LuxorsGiftClassless.png b/Projectiles/Typeless/LuxorsGiftClassless.png new file mode 100644 index 0000000000..923a4e34aa Binary files /dev/null and b/Projectiles/Typeless/LuxorsGiftClassless.png differ