From 0c8bcb7b5f16b41fac285eaae37ba24eae73bdd0 Mon Sep 17 00:00:00 2001 From: Doze-Zoze Date: Sat, 3 May 2025 19:14:28 -0500 Subject: [PATCH] mirror blade rework --- Items/Weapons/Melee/MirrorBlade.cs | 106 +++++++++-- Items/Weapons/Melee/MirrorBlade.png | Bin 1983 -> 3068 bytes ...Mods.CalamityMod.Items.Weapons.Melee.hjson | 8 +- .../Mods.CalamityMod.Projectiles.Melee.hjson | 1 + .../BaseCustomMeleeSwingProjectile.cs | 21 ++- Projectiles/CalamityGlobalProjectile.cs | 12 ++ Projectiles/Melee/MirrorBladeProjectile.cs | 109 +++++++++++ Projectiles/Melee/MirrorBladeProjectile.png | Bin 0 -> 2502 bytes Projectiles/Melee/MirrorBlast.cs | 169 +++++++++++++++--- Projectiles/Melee/MirrorBlast.png | Bin 596 -> 812 bytes Projectiles/Melee/MirrorShard.png | Bin 0 -> 613 bytes 11 files changed, 378 insertions(+), 48 deletions(-) create mode 100644 Projectiles/Melee/MirrorBladeProjectile.cs create mode 100644 Projectiles/Melee/MirrorBladeProjectile.png create mode 100644 Projectiles/Melee/MirrorShard.png diff --git a/Items/Weapons/Melee/MirrorBlade.cs b/Items/Weapons/Melee/MirrorBlade.cs index beda17aa01..6cca1f86a9 100644 --- a/Items/Weapons/Melee/MirrorBlade.cs +++ b/Items/Weapons/Melee/MirrorBlade.cs @@ -1,24 +1,40 @@ using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Rarities; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.DataStructures; +using Microsoft.Xna.Framework; +using CalamityMod.Systems.Collections; +using System; +using Terraria.Localization; namespace CalamityMod.Items.Weapons.Melee { - public class MirrorBlade : ModItem, ILocalizedModType + public class MirrorBlade : BaseSwordHoldoutItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - private int baseDamage = 100; + public override int ProjectileType => ModContent.ProjectileType(); + public float damageMultiplier = 1f; + public int reflectTimer = 0; + + public override void SetStaticDefaults() + { + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 5)); + ItemID.Sets.AnimatesAsSoul[Type] = true; + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + base.SetStaticDefaults(); + } public override void SetDefaults() { - Item.width = 72; - Item.height = 72; - Item.damage = baseDamage; - Item.DamageType = DamageClass.Melee; - Item.useAnimation = 12; - Item.useTime = 12; + Item.width = 114; + Item.height = 128; + Item.damage = 1000; + Item.DamageType = TrueMeleeDamageClass.Instance; + Item.useAnimation = 40; + Item.useTime = 40; Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 7f; @@ -28,20 +44,80 @@ namespace CalamityMod.Items.Weapons.Melee Item.rare = ModContent.RarityType(); Item.shootSpeed = 9f; Item.shoot = ModContent.ProjectileType(); + base.SetDefaults(); } - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) + public override void UpdateInventory(Player player) { - int conDamage = target.damage + baseDamage; - if (conDamage < baseDamage) + if (reflectTimer > 0) { - conDamage = baseDamage; + if (reflectTimer <= 50) + { + + float coneLength = 80f; + float maximumAngle = 0.8f; + float coneRotation = player.DirectionTo(Main.MouseWorld).ToRotation(); + var shardCount = 0; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == player.whoAmI && (proj.ModProjectile as MirrorBlast).isShard) + { + shardCount++; + } + } + foreach (var proj in Main.ActiveProjectiles) + { + if (proj.hostile && proj.damage > 0 && proj.Hitbox.IntersectsConeSlowMoreAccurate(player.Center, coneLength, coneRotation, maximumAngle)) + { + if (shardCount >= 10) + { + player.SetImmuneTimeForAllTypes(player.longInvince ? 60 : 30); + } + proj.Calamity().multiplicativeDR += shardCount / 10f; + proj.Calamity().multiplicativeDRTimer = 60; + foreach (var proj2 in Main.projectile) + { + if (proj2.active && proj2.type == ModContent.ProjectileType() && proj2.owner == player.whoAmI && (proj2.ModProjectile as MirrorBlast).isShard) + { + proj2.damage = (int)(proj2.damage * (shardCount >= 10 ? 3f : 2f)); + (proj2.ModProjectile as MirrorBlast).shardShield = 0; + (proj2.ModProjectile as MirrorBlast).shardNum = 11; + } + } + reflectTimer = 0; + return; + } + } + } + reflectTimer--; } - if (conDamage > 400) + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.altFunctionUse == 2) { - conDamage = 400; + reflectTimer = 60; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == player.whoAmI && (proj.ModProjectile as MirrorBlast).isShard) + { + (proj.ModProjectile as MirrorBlast).shardShield = 60; + } + } + return false; } - Item.damage = conDamage; + return base.Shoot(player, source, position, velocity, type, damage, knockback); + } + + public override bool AltFunctionUse(Player player) + { + return true; + } + + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) + { + //damage *= damageMultiplier; } } } diff --git a/Items/Weapons/Melee/MirrorBlade.png b/Items/Weapons/Melee/MirrorBlade.png index 5247456d75e51dd3250e865217f3c9eb8eec5741..3af0672f2807aabdd55798100745545408d8f990 100644 GIT binary patch literal 3068 zcmbVOd011&7EcIE(YO#OCV-fju*!O+2o_~YfE$E}(T9N|DkShyEYd(xzz9MOAQ5g7 zNL)a88mm?wOGE+1B1#|&YNd))v?_#$2v|WaQd!;vecxODeDi&ib7tnu%sJ=xJ9ASM z$p~Gt$Z8P^g<3*~X-pt_D3n3&XBeRE>wKIJ1Uiiw8icC7V>1EEfB) zMqun68NMwTk9S>XoAt+wd3Jbh^XWk_EzJC7etv$HMV2@D!KU~Jxs~&rgH@5N3=fF; z{n?*SYvzGXC2zn*XJBB2vO*i7&_D|V-TITR zkJb^5S(rBfx+mHIwH(M8(76SM3-ezCUEg+ruHXMJ`9GJUFensaf-(da9?)73boIwm z^*fBJKb}+ubbT`b=NK$lGJSo3_Gy==hlhUEF7(vVGhUaKDAb}&bXwrH{c%H2zS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4PqWdXo{Vi%Sil_$s{XBJc6V#|&(N{*e?be+Z^ zn<$kM)s_^3>}+VywGKv{YfV+2Acrbuu|&&vfzmJ5l1cy&nAcv}+%^%JP3F$@6Ms2oX zK(fZ?ylo*;*u1ZnKa&5>WMJG~Gn?YbcB4R0;oqTZ?q6Jw06N`&cs zc1>pQQoYdf1UXdENh>*-c})N$PYxFW#+FMjS!*nnJrh^O8yf*w+>$aTt*T0~$UZ-= znhzlQF4d{Z6XekUVvzQrwUd}1krl$0sA*;`+3(4HIYg@J7c3$KOa;QdkZP=YXopY^U|G1pL zRQCMs$;!+;Y9FR0DUMtJAG*ep&%XSks^`p7GNC5-?r3 diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index 4e7f11d90c..74d465d50e 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -858,8 +858,12 @@ MirrorBlade: { DisplayName: Mirror Blade Tooltip: ''' - The amount of contact damage an enemy does is added to this weapons' damage - You must hit an enemy with the blade to trigger this effect + Striking an enemy or a hostile projectile spawns mirror shards + You can have up to 10 mirror shards at once, and excess shards are launched at enemies + to form your shards into a mirror shield + Each shard redues the damage of a projectile that hit the shield by 10% + The shield breaks after one projectile, launching the shards at enemies with increasd damage + With all 10 shards, you gain a brief period of invulnerability when shattering the shield ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index 692b19f7df..952a0416ff 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -307,3 +307,4 @@ WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver YinYoDark.DisplayName: Dark Shard YinYoLight.DisplayName: Light Shard MutilatorSwordProj.DisplayName: The Mutilator +MirrorBladeProjectile.DisplayName: Mirror Blade diff --git a/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs b/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs index 73c7b4c53b..7aab71ad7f 100644 --- a/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs @@ -301,8 +301,15 @@ namespace CalamityMod.Projectiles.BaseProjectiles player.direction = -1; Projectile.spriteDirection = -1 * (int)player.gravDir; } + if (AlternateSwings && player.GetModPlayer().swingNum % 2 == 0) + { + Projectile.spriteDirection *= -1; + } swingTime = Main.player[Projectile.owner].HeldItem.useTime; Spawn(source); + StartupTime *= Projectile.MaxUpdates; + CooldownTime *= Projectile.MaxUpdates; + swingTime *= Projectile.MaxUpdates; if (useMeleeSpeed) { var speed = Main.player[Projectile.owner].GetAttackSpeed(); @@ -339,7 +346,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles { var player = Main.player[Projectile.owner]; var modplayer = player.GetModPlayer(); - float adust = MathHelper.ToRadians(45 + 180); + float adust = MathHelper.ToRadians(225); if (timer < StartupTime || timer > StartupTime + swingTime) { angle = Vector2.Lerp(angle, (player.Center - Main.MouseWorld).SafeNormalize(Vector2.One), RotateInStartup); @@ -369,16 +376,18 @@ namespace CalamityMod.Projectiles.BaseProjectiles oldProjectilePos.RemoveAt(0); } } - var angle2 = (AlternateSwings && (modplayer.swingNum % 2 == 1 ? false : true) ? SwingFunction() : -SwingFunction()); + var angle2 = (AlternateSwings && (modplayer.swingNum % 2 == 1 ? false : true) ? SwingFunction() : SwingFunction()); Projectile.Center = armCenter - (angle * OffsetDistance * (1 + (Projectile.scale - 1) * 0.75f)).RotatedBy(Projectile.spriteDirection * angle2); Projectile.rotation = angle.RotatedBy(Projectile.spriteDirection * angle2).ToRotation() + adust; AdditionalAI(); - player.itemTime = ExistsTime + 1 - timer; + player.itemTime = ExistsTime + 2 - timer; + player.itemAnimation = ExistsTime + 2 - timer; if (timer > ExistsTime) { - Projectile.Kill(); player.itemTime = 0; + player.itemAnimation = 0; + Projectile.Kill(); } timer++; if (timer >= StartupTime && timer < StartupTime + swingTime) @@ -427,7 +436,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["fireColor"].SetValue(trailColors[2].ToVector3()); - GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["flipped"].SetValue((AlternateSwings && modplayer.swingNum % 2 == 1) ^ Projectile.spriteDirection == -1 ? false : true); + GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["flipped"].SetValue(Projectile.spriteDirection == -1 ? false : true); GameShaders.Misc["CalamityMod:ExobladeSlash"].Apply(); var positionsToUse = Projectile.oldPos.Take((int)MathHelper.Min(trailLength,swingTimer)).ToArray(); @@ -485,7 +494,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles return; } amount += 1; - if (timer % (swingTime / amount) == 0 && timer > 0 && timer < swingTime - swingTime / amount / 2) + if (swingTimer % (swingTime / amount) == 0 && swingTimer > 0 && swingTimer < swingTime - swingTime / amount / 2) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.rotation + negate * MathHelper.ToRadians(45 - negate * 90)).ToRotationVector2() * velocity, type, (int)(Projectile.damage * damagemod), Projectile.knockBack, Projectile.owner, ai0); } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 9cbf6a12c9..02c5a9f444 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -219,6 +219,11 @@ namespace CalamityMod.Projectiles /// A temporary flat amount subtracted from the projectile's damage when hitting the player. Resets to 0 if drops to 0. public int flatDR = 0; + /// Timer for how long a projectile's damage is reduced by the value in . + public int multiplicativeDRTimer = 0; + /// A temporary multiplicative amount of damage reduction when hitting the player. Resets to 0 if drops to 0. + public float multiplicativeDR = 0; + /// If true, allows hostile projectiles to deal defense damage to the player. Used mostly for hard-hitting bosses. public bool DealsDefenseDamage = false; @@ -4006,6 +4011,12 @@ namespace CalamityMod.Projectiles if (flatDRTimer <= 0) flatDR = 0; } + if (projectile.FinalExtraUpdate() && multiplicativeDRTimer > 0) + { + multiplicativeDRTimer--; + if (multiplicativeDRTimer <= 0) + multiplicativeDR = 0; + } if (projectile.FinalExtraUpdate() && TransformerTimer > 0) { TransformerTimer--; @@ -4219,6 +4230,7 @@ namespace CalamityMod.Projectiles public override void ModifyHitPlayer(Projectile projectile, Player target, ref Player.HurtModifiers modifiers) { modifiers.FinalDamage.Flat -= flatDR; + modifiers.FinalDamage *= 1f - multiplicativeDR; } #endregion diff --git a/Projectiles/Melee/MirrorBladeProjectile.cs b/Projectiles/Melee/MirrorBladeProjectile.cs new file mode 100644 index 0000000000..6ccea31aa5 --- /dev/null +++ b/Projectiles/Melee/MirrorBladeProjectile.cs @@ -0,0 +1,109 @@ +using Terraria.ModLoader; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using CalamityMod.Items.Weapons.Melee; +using Terraria.DataStructures; +using System; +using System.Collections.Generic; + +namespace CalamityMod.Projectiles.Melee +{ + + public class MirrorBladeProjectile : BaseSwordHoldoutProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override int swingWidth => 200; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override int AfterImageLength => 10; + public override int OffsetDistance => 80; + public override bool drawSwordTrail => false; + public override Color[] trailColors => new Color[] { Color.Red, Color.MediumPurple, Color.Purple }; public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + public override bool AlternateSwings => true; + + public override bool useMeleeSpeed => true; + + public override int swingTime { get; set; } = 8; + + public List reflectedProjectiles = new List() { }; + + public override void Defaults() + { + Projectile.extraUpdates = 3; + } + + public override void Spawn(IEntitySource source) + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + StartupTime = 15; + CooldownTime = 15; + swingTime -= StartupTime + CooldownTime; + modplayer.swingNum = (modplayer.swingNum + 1) % 2; + Projectile.timeLeft = 600; + + } + + public override void AdditionalAI() + { + if (inStartup) + { + Projectile.scale = baseScale * MathHelper.Lerp(0.75f, 1f, StartupCompletion); + if (timer >= StartupTime - 1) + { + //Projectile.extraUpdates = 3; + + } + } + else if (inCooldown) + { + //Projectile.extraUpdates = 1; + Projectile.Opacity = 1; + Projectile.scale = baseScale * MathHelper.Lerp(1, 0.75f, CooldownCompletion); + } + else + { + //Projectile.extraUpdates = 1; + Projectile.Opacity = 1; + } + if (!inStartup && !inCooldown) + foreach (var proj in Main.ActiveProjectiles) + { + if (proj.Hitbox.Intersects(Projectile.Hitbox) && proj.hostile && !reflectedProjectiles.Contains(proj.whoAmI)) + { + reflectedProjectiles.Add(proj.whoAmI); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), proj.Center, proj.velocity * -1, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); + } + } + + Lighting.AddLight(Main.player[Projectile.owner].Center, 0.96f, 0.91f, 1f); + } + + public override float SwingFunction() + { + if (inStartup) + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * 0.7f, -swingWidth * 0.4f, 1 - MathF.Pow(StartupCompletion, 0.5f))); + if (inCooldown) + return MathHelper.ToRadians(MathHelper.SmoothStep(swingWidth * 0.5f, (360 - swingWidth * 0.4f), MathF.Pow(CooldownCompletion, 0.5f))); + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * .5f, (swingWidth * 0.5f), SwingCompletion)); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); + } + public override float trailOffset => 28; + public override float trailWidth(float completion) + { + return 60;//base.trailWidth(completion)*2; + } + public override int trailLength => 40; + public override bool PreDraw(ref Color lightColor) + { + lightColor = Color.White; + return base.PreDraw(ref lightColor); + } + } +} \ No newline at end of file diff --git a/Projectiles/Melee/MirrorBladeProjectile.png b/Projectiles/Melee/MirrorBladeProjectile.png new file mode 100644 index 0000000000000000000000000000000000000000..56f94280f2717ea7403ea8112b0c96d509f2855d GIT binary patch literal 2502 zcmX9=2{@Gd7ygZLB@#6%%c$H5lM*wwT;!4lSuQemaT(NDlDSis)cm`;Qr1voG)z>M zu_a>}8B3NC!X3NPHPxLfTe7qm{J-IQp5J%A=Q+=J&Uw%Kp7VW)jt*8bQc6+)02v!= zOJ~SNLWd$L0o_LuOfNwOMsl{Y0OhZd(*W!YvavLGiF!Ckj|Ijnm1$?`Ae`Iml8OdhyZ3-2EukQe(F(dhs*HO!=n(kFG$ z1BQ$?TubF;@X*W@!xs=AYZRs1q_{BE+6#d7A$O%`bfxK?M8drc{mNaG+DWfHVo_7Y zhCkPwLz$W<+eQ8rd;p#n7jqo=);FU4jrIRV404aC4HNN>TYl$!JoCodk}4y_wIn^4 zfm2t!ms}qm4G1^8 zf9@76i2vi(R0L;yk4i3=`@FN4djzG`TZhN?mv-$z_?-7(Nl+gCy!2ZUF6O3E_7MVs zs>zyfKBh|95nKjmToD+6`zDJj%tjYx=WcmGd~66|Y{j>*03nH+`mH|cgEdRDnyd%g z^6bP_EoSgmR4GSa9)$h!d~tqlfi-T+iivA^0H?^(Hg-dOgOE@|bZuc=?(K)k@77zQ zW>_xFX)8O{_#1EOZNFq!$Dj5KxLHG2yGplAE2isDTg?&25G{>>h8HUMy$?wPrlTjk zT)o{b0qT7ZxAY=Fo?;n^e}0}|KQ#S1(!?#UaD~nA69XRbZZS$@!iZ-c6Y8X*q6R_B z!DCSY+@Teo2^G-3Eu)@#u6H~4+hM`r%#jifqDQk9E zzHlfR`XZ&2{=eLO^)9I{5xQy{|LdsBaQK#0!<* zep#}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R8n4B@x~MQc9h6&9DA7U7 zve45N+)9nXyabws)?2R}supOoNT4J;_ssQX!}_lWMt-fOhxj=- z*ns}wpj@#Ng_peD!Ur45BGrNZ<{OopuQ8(+#_EL=B%nZ}D}rm)u?;J6oB}9m8r^g+ z<^KJbuB$eyTxwB>yB=IyX-%&}1>TptE(^-athA#8?iJq(3TWS0uwgH95ik5P` zH17I(?jiVrmCn}8q;+J!(ahl)$6Fk%54+`{kX{{hmyvbF#K literal 0 HcmV?d00001 diff --git a/Projectiles/Melee/MirrorBlast.cs b/Projectiles/Melee/MirrorBlast.cs index bcf7c10932..92210ff77f 100644 --- a/Projectiles/Melee/MirrorBlast.cs +++ b/Projectiles/Melee/MirrorBlast.cs @@ -3,61 +3,180 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; namespace CalamityMod.Projectiles.Melee { public class MirrorBlast : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + public bool isShard = true; + + public int shardShield = 0; + + public bool isShield => shardShield > 0; + + private bool hasSpawned = false; + + public int shardNum = -1; + + private Player player => Main.player[Projectile.owner]; public override void SetStaticDefaults() { - ProjectileID.Sets.TrailCacheLength[Type] = 10; - ProjectileID.Sets.TrailingMode[Type] = 1; + Main.projFrames[Type] = 3; } public override void SetDefaults() { - Projectile.width = 12; - Projectile.height = 12; + Projectile.width = 16; + Projectile.height = 16; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = 1; - Projectile.timeLeft = 300; + Projectile.timeLeft = 1800; + Projectile.extraUpdates = 0; + Projectile.tileCollide = false; } + public override bool? CanDamage() + { + return !isShard; + } + + public override bool? CanHitNPC(NPC target) + { + if (target.Calamity().DR > 0.9f) { + return false; + } + return base.CanHitNPC(target); + } public override void AI() { - int playerOwner = (int)Player.FindClosest(Projectile.Center, 1, 1); - Projectile.ai[1] += 1f; - if (Projectile.ai[1] < 110f && Projectile.ai[1] > 30f) + if (!hasSpawned) { - float scaleFactor = Projectile.velocity.Length(); - Vector2 projDirection = Main.player[playerOwner].Center - Projectile.Center; - projDirection.Normalize(); - projDirection *= scaleFactor; - Projectile.velocity = (Projectile.velocity * 24f + projDirection) / 25f; - Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor; + shardNum = player.ownedProjectileCounts[Projectile.type]; + hasSpawned = true; + shardNum = 0; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == Projectile.owner) + { + (proj.ModProjectile as MirrorBlast).shardNum++; + } + } + } + if (isShield) + { + if (shardNum > 10) + { + shardShield = 0; + isShard = false; + Projectile.timeLeft = 1200; + Projectile.velocity = Projectile.DirectionTo(player.Center) * -20f; + return; + } + List positions = new List() + { + new(0,75), + new(10,65), + new(-10,65), + new(20,75), + new(-20,75), + new(30,65), + new(-30,65), + new(14,55), + new(-14,55), + new(0,45) + }; + Projectile.velocity = Vector2.Zero; + Projectile.Center = Vector2.Lerp(Projectile.Center, + player.Center + player.DirectionTo(player.Calamity().mouseWorld) + .RotatedBy(MathHelper.ToRadians(positions[shardNum - 1].X)) + * positions[shardNum - 1].Y, + 0.5f); + Projectile.rotation = Projectile.DirectionTo(player.Center).ToRotation() + MathHelper.PiOver2; + shardShield--; + } + else if (isShard) + { + Projectile.velocity = Vector2.Zero; + var shardCount = 0; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == Projectile.owner && (proj.ModProjectile as MirrorBlast).isShard) + { + shardCount++; + } + } + Projectile.Center = Vector2.Lerp(Projectile.Center, player.Center + new Vector2(0, MathHelper.Lerp(-90, -110, MathF.Sin(player.miscCounter / 300f * MathHelper.TwoPi + MathHelper.Pi * (shardNum % 2)))).RotatedBy(MathHelper.ToRadians(player.miscCounter / 300f * 360f + 360f / shardCount * shardNum)), 0.15f); + Projectile.rotation = Projectile.DirectionTo(player.Center).ToRotation() + MathHelper.PiOver2; + if (shardNum > 10 || Projectile.timeLeft < 2) + { + isShard = false; + Projectile.timeLeft = 1200; + Projectile.velocity = Projectile.DirectionTo(player.Center) * -20f; + } + } + else + { + float homingStrength = 0.025f; // Adjust this value for stronger or weaker homing + NPC target = FindClosestNPC(3200f); + if (target != null) + { + Vector2 direction = target.Center - Projectile.Center; + direction.Normalize(); + direction *= 40f; // Adjust speed as needed + Projectile.velocity = Vector2.Lerp(Projectile.velocity, direction, homingStrength); + } + Projectile.rotation = Projectile.velocity.ToRotation(); } - if (Projectile.velocity.Length() < 18f) + Lighting.AddLight(Projectile.Center, 0.96f*0.33f, 0.91f*0.33f, 0.33f); + if (Projectile.FinalExtraUpdate()) + Projectile.frameCounter++; + if (Projectile.frameCounter > 8) { - Projectile.velocity *= 1.02f; + Projectile.frame++; + Projectile.frameCounter = 0; } - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - - Lighting.AddLight(Projectile.Center, 0f, 0.35f, 0.35f); + if (Projectile.frame >= 3) + Projectile.frame = 0; } public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft > 295) - return false; - - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); + Texture2D BlastTex = ModContent.Request("CalamityMod/Projectiles/Melee/MirrorBlast").Value; + Texture2D ShardTex = ModContent.Request("CalamityMod/Projectiles/Melee/MirrorShard").Value; + Point BlastTextureDim = new Point(60, 26); + Point ShardTextureDim = new Point(32, 14); + Texture2D UsedTex = isShard ? ShardTex : BlastTex; + Point UsedTextureDim = isShard ? ShardTextureDim : BlastTextureDim; + Vector2 origin = isShard ? ShardTextureDim.ToVector2() / 2f : BlastTextureDim.ToVector2() / 2f + new Vector2(14, 0); + Main.spriteBatch.Draw(UsedTex, Projectile.Center - Main.screenPosition, new Rectangle(0, UsedTextureDim.Y * Projectile.frame, UsedTextureDim.X, UsedTextureDim.Y), Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0f); return false; } + + private NPC FindClosestNPC(float maxRange) + { + NPC closestNPC = null; + float closestDistance = maxRange; + + foreach (NPC npc in Main.npc) + { + if (npc.CanBeChasedBy(this) && !npc.friendly) + { + float distance = Vector2.Distance(Projectile.Center, npc.Center); + if (distance < closestDistance) + { + closestDistance = distance; + closestNPC = npc; + } + } + } + + return closestNPC; + } } } diff --git a/Projectiles/Melee/MirrorBlast.png b/Projectiles/Melee/MirrorBlast.png index ae7a902f9af39d754ff9e68358c2eee7a587d965..07a472095784e2534f6f4782de1f888465a55297 100644 GIT binary patch literal 812 zcmeAS@N?(olHy`uVBq!ia0vp^HbCsh!3-q5PqcOcDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheasfUeu0Yyct}4Z6UBle}i%$Lj_Tqm}<>eiV9{>OUA1GC(X!aLKag_x5 z1p`GOfML@ao%29Z&H|6fVg?4j!ywFfJby(BP*9@8HKHUqKdq!Zu_%=xATcwqM9$cc0dZzK3s^i0$OeG~AO`7&(P)-30K;PfI|B<)g@KW=0pkLQsURJ!3m_&<0kT1W z31|)zSY?o<1&{^RWoTdkl2vt|*Spwc>rtR>vproLLn7SIUca4p*norW!H*el{>E1* zO)2cyIO&1c@AXz^(kt`4r@mF6a8_*I6Zwa4&#cJG&Nd9Xd1~sH&KJ+7KcD~J(EQYr zDaD#guS8{Mul?#LUBiD^u{wY4lzYYR_I|Iu|NUAYvw1}0%O;(?wP8yH4ipqTI6kph zCRw{^FJp{YOvu`jl$L@wQy$Iex4p&C@86^M`pu%W)cFsyO`h{F|NU`FWZPS*qwyUH z&$gYLsq1P`6g_#SzMDZxS;_Jc6Pf=+rDKVUKxLJj<~FS zT(`mJo>t$|{tq4Y62HWp;u0b++NNI>Q&9A|6P7!tO<>>j_X*Xhi+6N0`jniTyEOI2 z^K*xobEHj{TEz222$iY&trU^jdH8sXz_&;*i+=)^{hZtzmYMvRa4EUzcemgn<-W6D zW*Er+@-}?-EV(Il#_Sn8YJ8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