diff --git a/Buffs/Summon/KalandraMirrorBuff.cs b/Buffs/Summon/KalandraMirrorBuff.cs new file mode 100644 index 0000000000..6882b77d11 --- /dev/null +++ b/Buffs/Summon/KalandraMirrorBuff.cs @@ -0,0 +1,35 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon.MirrorofKalandraMinions; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class KalandraMirrorBuff : ModBuff + { + public override void SetStaticDefaults() + { + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + //Main.persistentBuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + modPlayer.KalandraMirror = true; + } + if (!modPlayer.KalandraMirror) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/KalandraMirrorBuff.png b/Buffs/Summon/KalandraMirrorBuff.png new file mode 100644 index 0000000000..5c96dedec4 Binary files /dev/null and b/Buffs/Summon/KalandraMirrorBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index f7462d1401..7df6daf9a3 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -976,6 +976,7 @@ namespace CalamityMod.CalPlayer public bool MoonFist = false; public bool AresCannons = false; public bool celestialDragons = false; + public bool KalandraMirror = false; public List PendingProjectilesToRespawn = new List(); @@ -2013,6 +2014,7 @@ namespace CalamityMod.CalPlayer MoonFist = false; AresCannons = false; celestialDragons = false; + KalandraMirror = false; disableVoodooSpawns = false; disablePerfCystSpawns = false; diff --git a/Items/Weapons/Summon/MirrorofKalandra.cs b/Items/Weapons/Summon/MirrorofKalandra.cs new file mode 100644 index 0000000000..c4db48fd77 --- /dev/null +++ b/Items/Weapons/Summon/MirrorofKalandra.cs @@ -0,0 +1,106 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Summon.MirrorofKalandraMinions; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class MirrorofKalandra : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Summon"; + + public static float TargetDistanceDetection = 2500f; + public static float IdleDistanceFromPlayer = 250f; + public static float OscillationSpeed = .025f; + public static float OscillationRange = 8; // The bigger the number, the smaller the range is. + + public static float Axe_MinRamSpeed = 30f; + public static float Axe_MaxRamSpeed = 50f; + public static int Axe_IFrames = 15; + public static float Axe_SpinSpeed = 25f; // In degrees per frame. + + public static float Purple_MinRamSpeed = 40f; + public static float Purple_MaxRamSpeed = 60f; + public static int Purple_IFrames = 15; + public static float Purple_BlastDMGModifier = 3f; + public static float Purple_BlastFireRate = 180f; // In frames. + public static int Purple_BlastSize = 300; + public static int Purple_BlastChargeTime = 10; + public static float Purple_SpinSpeed = 25f; // In degrees per frame. + + public static int Scimitar_IFrames = 15; + + public static int Wind_BowChargeTime = 5; // Therefore, the higher the time, the slower the fire rate will be, and viceversa. + public static float Wind_ArrowSpeed = 50f; + + public static int Vile_BowChargeTime = 8; + public static float Vile_ArrowSpeed = 50f; + public static float Vile_SplitDMGMultiplier = .33f; + public static int Vile_SplitSpreadAngle = 8; // In degrees. + + public override void SetDefaults() + { + Item.damage = 380; + Item.useTime = Item.useAnimation = 30; + Item.shootSpeed = 20f; + Item.knockBack = 4f; + Item.mana = 10; + Item.shoot = ModContent.ProjectileType(); + + Item.width = 58; + Item.height = 50; + Item.autoReuse = true; + Item.noMelee = true; + Item.DamageType = DamageClass.Summon; + Item.useStyle = ItemUseStyleID.Shoot; + Item.UseSound = SoundID.Item4; + Item.rare = ModContent.RarityType(); + Item.value = CalamityGlobalItem.Rarity14BuyPrice; + } + + public override Vector2? HoldoutOffset() => new Vector2(-15, 0); + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[ModContent.ProjectileType()] != 1; + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.ownedProjectileCounts[ModContent.ProjectileType()] == 1) + { + type = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] != 1) + type = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] != 1) + type = ModContent.ProjectileType(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] != 1) + type = ModContent.ProjectileType(); + } + + int minion = Projectile.NewProjectile(source, player.Center, Vector2.Zero, type, damage, knockback, player.whoAmI); + if (Main.projectile.IndexInRange(minion)) + Main.projectile[minion].rotation = -MathHelper.PiOver2; + + return false; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddIngredient(10). + AddIngredient(ItemID.MagicMirror). + AddCondition(Condition.NearShimmer). + Register(); + + CreateRecipe(). + AddIngredient(10). + AddIngredient(10). + AddIngredient(ItemID.MagicMirror). + AddIngredient(ItemID.BottomlessShimmerBucket). + Register(); + } + } +} diff --git a/Items/Weapons/Summon/MirrorofKalandra.png b/Items/Weapons/Summon/MirrorofKalandra.png new file mode 100644 index 0000000000..292b4534c8 Binary files /dev/null and b/Items/Weapons/Summon/MirrorofKalandra.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index ca2c699258..96fcafe927 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -1435,4 +1435,9 @@ WitherBlossomsBuff: { WulfrumDroidBuff: { DisplayName: Wulfrum Droid Description: The wulfrum droid will protect you +} + +KalandraMirrorBuff: { + DisplayName: Mirror of Kalandra + Description: Five ancient weapons will annihilate your enemies } \ No newline at end of file diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson index 0d9318bc56..0e530c23ff 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson @@ -328,12 +328,12 @@ LunicCorpsHelmet: { SetBonus: ''' 'Finish the fight' - Provides an energy shield that absorbs up to 70 damage + Provides an energy shield that absorbs up to 70 damage The shield recharges over 10 seconds after being broken Getting hit during the shield recharge period will restart the recharging process - 10% increased bullet damage - 10% increased specialist ranged damage - These are launchers, dartguns, or anything else that doesn't shoot arrows/bullets + 10% increased bullet damage + 10% increased specialist ranged damage + These are launchers, dartguns, or anything else that doesn't shoot arrows/bullets 20% increased jump speed ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index a491b3bd51..c4660c8341 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -770,4 +770,19 @@ YharonsKindleStaff: { Summons a fiery draconid to fight for you Requires 5 minion slots to use ''' +} + +MirrorofKalandra: { + DisplayName: Mirror of Kalandra + Tooltip: + ''' + Summons five ancient weapons to annihilate your enemies + There can only be one of each individual weapon + [c/BD7F59:Atziris' Disfavor brutally cleaves through enemies] + [c/E7A7FF:Starforge rips through foes and occasionally induces cosmic explosions] + [c/868B8F:Paradoxica teleports to enemies and blitzes through them at high speed] + [c/EBC3A5:Wind Ripper unleashes a single high-speed, powerful arrow at enemies] + [c/9B6856:Hope Shredder shoots arrows that split into three and pierce enemies twice] + 'Ultimate, Immeasurable, Indescribable' + ''' } \ No newline at end of file diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index 37168b1091..1840663c77 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -297,4 +297,13 @@ WulfrumEnergyBurst.DisplayName: Bolt WulfrumFusionBolt.DisplayName: Fusion Bolt YharonMinionFireball.DisplayName: Dragon Fireball YoungDuke.DisplayName: Young Old Duke -IceClasperSummonProjectile.DisplayName: Ice Shard \ No newline at end of file +IceClasperSummonProjectile.DisplayName: Ice Shard +AtzirisDisfavor.DisplayName: Atziris Disfavor +Starforge.DisplayName: Starforge +Paradoxica.DisplayName: Paradoxica +StarforgeBlast.DisplayName: Starforge Blast +WindRipper.DisplayName: Wind Ripper +WindRipperArrow.DisplayName: Wind Ripper Arrow +HopeShredder.DisplayName: Hope Shredder +HopeShredderArrow.DisplayName: Hope Shredder Arrow +HopeShredderArrowSplit.DisplayName: Hope Shredder Arrow Split \ No newline at end of file diff --git a/Projectiles/Summon/MirrorofKalandraMinions/AtzirisDisfavor.cs b/Projectiles/Summon/MirrorofKalandraMinions/AtzirisDisfavor.cs new file mode 100644 index 0000000000..e721031264 --- /dev/null +++ b/Projectiles/Summon/MirrorofKalandraMinions/AtzirisDisfavor.cs @@ -0,0 +1,132 @@ +using System; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Particles; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions +{ + public class AtzirisDisfavor : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer ModdedOwner => Owner.Calamity(); + public NPC Target => Projectile.Center.MinionHoming(MirrorofKalandra.TargetDistanceDetection, Owner); + public ref float DrawSpin => ref Projectile.ai[0]; + public ref float Oscillation => ref Projectile.ai[1]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 4; + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 12000; + } + + public override void SetDefaults() + { + Projectile.minionSlots = 1; + Projectile.localNPCHitCooldown = MirrorofKalandra.Axe_IFrames; + Projectile.penetrate = -1; + + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 112; + Projectile.minion = true; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + } + + public override void AI() + { + CheckMinionExistence(); + + // Flavor visual dust effect. + if (Main.rand.NextBool(3)) + { + int flavorDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 228, 0, 0, 0, default, 1.2f); + Main.dust[flavorDust].noGravity = true; + } + + if (Target is not null) + { + // The distance to the target plus a small number so it's not 0, it'd break calculations. + float distanceToTarget = Projectile.Distance(Target.Center) + .01f; + + // The minion will head towards it's rotation. + // If the target's close, the minion'll speed up, and viceversa, so it doesn't circle around the target doing nothing. + Projectile.velocity = Projectile.rotation.ToRotationVector2() * (MirrorofKalandra.Axe_MinRamSpeed + (12f / (distanceToTarget * .01f))); + Projectile.velocity = Vector2.Clamp(Projectile.velocity, Vector2.One * -MirrorofKalandra.Axe_MaxRamSpeed, Vector2.One * MirrorofKalandra.Axe_MaxRamSpeed); + Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.AngleTo(Target.Center), .001f * distanceToTarget); + + // Swing effect. + SemiCircularSmearVFX swingTrail = new SemiCircularSmearVFX(Projectile.Center + (DrawSpin + MathHelper.Pi).ToRotationVector2() * 10f, // Weird vector calculation for better alignment. + Color.OrangeRed, + DrawSpin + MathHelper.PiOver2, + Projectile.scale * .8f, + Vector2.One); + GeneralParticleHandler.SpawnParticle(swingTrail); + + // Repeating swing sound. + if (Projectile.soundDelay <= 0) + { + SoundEngine.PlaySound(CommonCalamitySounds.LouderSwingWoosh with { Pitch = -.8f, PitchVariance = 1f, Volume = .6f }, Projectile.Center); + Projectile.soundDelay = 15; + Projectile.netUpdate = true; + } + } + else if (Target is null) + { + Projectile.Center = Vector2.Lerp(Projectile.Center, + Owner.Center + Projectile.rotation.ToRotationVector2() * (MirrorofKalandra.IdleDistanceFromPlayer + MirrorofKalandra.IdleDistanceFromPlayer * (MathF.Sin(Oscillation) / MirrorofKalandra.OscillationRange)), + .3f); + Projectile.velocity = Vector2.Zero; + Projectile.rotation = Projectile.rotation.AngleLerp(-MathHelper.PiOver2, .1f); + Oscillation += MirrorofKalandra.OscillationSpeed; + } + } + + public void CheckMinionExistence() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Projectile.type != ModContent.ProjectileType()) + return; + + if (Owner.dead) + ModdedOwner.KalandraMirror = false; + if (ModdedOwner.KalandraMirror) + Projectile.timeLeft = 2; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + ImpactParticle sparkHit = new ImpactParticle(Vector2.Lerp(Projectile.Center, target.Center, .8f), + Main.rand.NextBool().ToDirectionInt() * Main.rand.NextFloat(.08f, .12f), + 20, + 1f, + Color.Gold); + GeneralParticleHandler.SpawnParticle(sparkHit); + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + DrawSpin += MathHelper.ToRadians(MirrorofKalandra.Axe_SpinSpeed); + float rotation = (Target is not null) ? DrawSpin : Projectile.rotation + MathHelper.PiOver4; + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), rotation, origin, Projectile.scale, SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/Summon/MirrorofKalandraMinions/AtzirisDisfavor.png b/Projectiles/Summon/MirrorofKalandraMinions/AtzirisDisfavor.png new file mode 100644 index 0000000000..16a6b03356 Binary files /dev/null and b/Projectiles/Summon/MirrorofKalandraMinions/AtzirisDisfavor.png differ diff --git a/Projectiles/Summon/MirrorofKalandraMinions/HopeShredder.cs b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredder.cs new file mode 100644 index 0000000000..ee476116ef --- /dev/null +++ b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredder.cs @@ -0,0 +1,120 @@ +using System; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions +{ + public class HopeShredder : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer ModdedOwner => Owner.Calamity(); + public NPC Target => Projectile.Center.MinionHoming(MirrorofKalandra.TargetDistanceDetection, Owner); + public ref float Oscillation => ref Projectile.ai[0]; + + public override void SetStaticDefaults() => Main.projFrames[Type] = 7; + + public override void SetDefaults() + { + Projectile.penetrate = -1; + + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 84; + Projectile.minion = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.friendly = true; + } + + public override void AI() + { + CheckMinionExistence(); + + Projectile.Center = Vector2.Lerp(Projectile.Center, Owner.Center + (-MathHelper.PiOver2 + MathHelper.PiOver4 * 1.5f).ToRotationVector2() * (MirrorofKalandra.IdleDistanceFromPlayer + MirrorofKalandra.IdleDistanceFromPlayer * (MathF.Sin(Oscillation) / MirrorofKalandra.OscillationRange)), .4f); + Projectile.velocity = Vector2.Zero; + Oscillation += MirrorofKalandra.OscillationSpeed; + + if (Target is not null) + { + DoAnimation(); + ShootTarget(); + + Projectile.rotation = Projectile.rotation.AngleTowards(CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, Target, MirrorofKalandra.Vile_ArrowSpeed).ToRotation(), .2f); + } + else + { + Projectile.frame = 0; + Projectile.rotation = Projectile.rotation.AngleTowards(-MathHelper.PiOver2 + MathHelper.PiOver4 * 1.5f, .2f); + } + } + + public void DoAnimation() + { + Projectile.frameCounter++; + if (Projectile.frameCounter % MirrorofKalandra.Vile_BowChargeTime == 0) + Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type]; + } + + public void ShootTarget() + { + // On the first frame where the projectile is on the firing frame animation, fire an arrow. + if (Projectile.frame == 5 && Projectile.frameCounter % MirrorofKalandra.Vile_BowChargeTime == 0 && Main.myPlayer == Projectile.owner) + { + Vector2 spawnPosition = Projectile.Center + Projectile.rotation.ToRotationVector2() * (Projectile.width / 2); + int arrow = Projectile.NewProjectile(Projectile.GetSource_FromThis(), + spawnPosition, + CalamityUtils.CalculatePredictiveAimToTarget(spawnPosition, Target, MirrorofKalandra.Vile_ArrowSpeed), + ModContent.ProjectileType(), + (int)(Projectile.damage / MirrorofKalandra.Vile_SplitDMGMultiplier), + Projectile.knockBack, + Owner.whoAmI); + + if (Main.projectile.IndexInRange(arrow)) + Main.projectile[arrow].originalDamage = (int)(Projectile.originalDamage / MirrorofKalandra.Vile_SplitDMGMultiplier); + + SoundEngine.PlaySound(SoundID.Item5, Owner.Center); + + Projectile.netUpdate = true; + } + } + + public void CheckMinionExistence() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Projectile.type != ModContent.ProjectileType()) + return; + + if (Owner.dead) + ModdedOwner.KalandraMirror = false; + if (ModdedOwner.KalandraMirror) + Projectile.timeLeft = 2; + } + + public override bool? CanDamage() => false; + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + + // These two entity sprite draws are afterimages. + Main.EntitySpriteDraw(texture, drawPosition - Projectile.rotation.ToRotationVector2() * 5f, frame, Color.DarkBlue with { A = 100 }, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(texture, drawPosition + Projectile.rotation.ToRotationVector2() * 5f, frame, Color.DarkBlue with { A = 100 }, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + + + return false; + } + } +} diff --git a/Projectiles/Summon/MirrorofKalandraMinions/HopeShredder.png b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredder.png new file mode 100644 index 0000000000..3877a46430 Binary files /dev/null and b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredder.png differ diff --git a/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrow.cs b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrow.cs new file mode 100644 index 0000000000..798f3b56a3 --- /dev/null +++ b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrow.cs @@ -0,0 +1,79 @@ +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions +{ + public class HopeShredderArrow : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public Player Owner => Main.player[Projectile.owner]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 5; + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 12000; + } + + public override void SetDefaults() + { + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 22; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation(); + } + + public override void Kill(int timeLeft) + { + for (int i = -MirrorofKalandra.Vile_SplitSpreadAngle; i < MirrorofKalandra.Vile_SplitSpreadAngle * 2; i += MirrorofKalandra.Vile_SplitSpreadAngle) + { + int shard = Projectile.NewProjectile(Projectile.GetSource_FromThis(), + Projectile.Center, + Projectile.velocity.RotatedBy(MathHelper.ToRadians(i)), + ModContent.ProjectileType(), + Projectile.damage, + Projectile.knockBack, + Owner.whoAmI); + + if (Main.projectile.IndexInRange(shard)) + Main.projectile[shard].originalDamage = Projectile.originalDamage; + + Projectile.netUpdate = true; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + Color afterimageDrawColor = Color.Gray with { A = 125 } * Projectile.Opacity * (1f - i / (float)Projectile.oldPos.Length); + Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + Main.EntitySpriteDraw(texture, afterimageDrawPosition, frame, afterimageDrawColor, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + } + } + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrow.png b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrow.png new file mode 100644 index 0000000000..164b16a9b8 Binary files /dev/null and b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrow.png differ diff --git a/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrowSplit.cs b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrowSplit.cs new file mode 100644 index 0000000000..6b3ff8868b --- /dev/null +++ b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrowSplit.cs @@ -0,0 +1,29 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions +{ + public class HopeShredderArrowSplit : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public override void SetStaticDefaults() => ProjectileID.Sets.MinionShot[Type] = true; + + public override void SetDefaults() + { + Projectile.penetrate = 3; + + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 18; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation(); + } + } +} diff --git a/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrowSplit.png b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrowSplit.png new file mode 100644 index 0000000000..b2d29cbadc Binary files /dev/null and b/Projectiles/Summon/MirrorofKalandraMinions/HopeShredderArrowSplit.png differ diff --git a/Projectiles/Summon/MirrorofKalandraMinions/Paradoxica.cs b/Projectiles/Summon/MirrorofKalandraMinions/Paradoxica.cs new file mode 100644 index 0000000000..0f392996a2 --- /dev/null +++ b/Projectiles/Summon/MirrorofKalandraMinions/Paradoxica.cs @@ -0,0 +1,206 @@ +using System; +using System.IO; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Particles; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions +{ + public class Paradoxica : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer ModdedOwner => Owner.Calamity(); + public NPC Target => Projectile.Center.MinionHoming(MirrorofKalandra.TargetDistanceDetection, Owner); + public ref float AITimer => ref Projectile.ai[0]; + public ref float Oscillation => ref Projectile.ai[1]; + public bool hasTeleported = false; + public Vector2 ChargeStartingPosition; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5; + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 12000; + } + + public override void SetDefaults() + { + Projectile.minionSlots = 1; + Projectile.localNPCHitCooldown = MirrorofKalandra.Scimitar_IFrames; + Projectile.penetrate = -1; + + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 104; + Projectile.ignoreWater = true; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.minion = true; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(hasTeleported); + writer.WriteVector2(ChargeStartingPosition); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + hasTeleported = reader.ReadBoolean(); + ChargeStartingPosition = reader.ReadPackedVector2(); + } + + public override void AI() + { + CheckMinionExistence(); + + if (Main.rand.NextBool(30)) + { + GenericSparkle sparkle = new GenericSparkle(Projectile.Center + Main.rand.NextVector2Circular(Projectile.width / 4, Projectile.height / 4), + Vector2.Zero, + Color.Lerp(Color.White, Color.Gold, Main.rand.NextFloat(1f)), + Color.White, + Main.rand.NextFloat(.6f, 1f), + 20, + Main.rand.NextFloat(.08f, .12f), + Main.rand.NextFloat(.1f, .3f)); + GeneralParticleHandler.SpawnParticle(sparkle); + } + + if (Target is not null) + { + if (!hasTeleported) + { + int dustAmount = 60; + for (int dustIndex = 0; dustIndex < dustAmount; dustIndex++) + { + float angle = MathHelper.TwoPi / dustAmount * dustIndex; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(5f, 15f); + Dust teleportDust = Dust.NewDustPerfect(Projectile.Center, 212, velocity); + teleportDust.noGravity = true; + } + + Projectile.Center = Target.Center; + hasTeleported = true; + } + + // + // Code from Virid Vanguard @ DoBehaviour_RegularPierceSlashes(). + // + + int attackCycleTime = ViridVanguard.PierceChargeAttackCycleTime; + float upwardRiseTimeRatio = 0.4f; + float pierceTimeRatio = 0.14f; + + // Initialize the starting position on the first frame. + int localAITimer = (int)AITimer; + if (localAITimer % attackCycleTime == 1f) + { + ChargeStartingPosition = Projectile.Center + Main.rand.NextVector2Circular(80f, 80f); + Projectile.netUpdate = true; + } + + float attackCompletion = localAITimer / (float)attackCycleTime % 1f; + + // Reset the trail point array if aiming at the target. + if (attackCompletion < upwardRiseTimeRatio) + Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; + + // Use extra updates to make the swords move faster than normal. + Projectile.MaxUpdates = 2; + + // This represents the entire attack cycle in a single interpolant via a bunch of GetLerpValues and vector math. The patterns is as follows: + // 1. Hover very quickly to the starting position. + // 2. Rise upward somewhat. + // 3. Lerp towards the target rapidly. + // 4. Lerp through the target rapidly. + // 5. Repeat. + float offsetDistanceFactor = MathHelper.Lerp(1.61f, 3f, 1f / 7f % 1f); + Vector2 startingPosition = ChargeStartingPosition + Vector2.UnitY * Utils.GetLerpValue(0f, upwardRiseTimeRatio, attackCompletion, true) * -200f; + Vector2 targetOffset = Target.Center - startingPosition; + Vector2 endingPosition = Target.Center + targetOffset.SafeNormalize(Vector2.Zero) * MathHelper.Clamp(targetOffset.Length(), 60f, 240f) * offsetDistanceFactor; + float pierceCompletion = Utils.GetLerpValue(upwardRiseTimeRatio, upwardRiseTimeRatio + pierceTimeRatio, attackCompletion, true); + float throughTargetCompletion = Utils.GetLerpValue(upwardRiseTimeRatio + pierceTimeRatio, 1f, attackCompletion, true); + + // Update rotation and interpolate through the necessary positions. + Projectile.rotation = Projectile.rotation.AngleTowards(targetOffset.ToRotation() + MathHelper.PiOver2, MathHelper.Pi / 5f); + Projectile.Center = Vector2.Lerp(Projectile.Center, Vector2.Lerp(startingPosition, Target.Center, pierceCompletion), pierceCompletion * 0.5f); + if (throughTargetCompletion > 0f) + Projectile.Center = Vector2.Lerp(Target.Center, endingPosition, throughTargetCompletion); + Projectile.velocity = Vector2.Zero; + + // Play a slice sound once ready to charge. + if (localAITimer % attackCycleTime == (int)(attackCycleTime * upwardRiseTimeRatio)) + SoundEngine.PlaySound(CommonCalamitySounds.MeatySlashSound with { Pitch = 1.6f, Volume = 0.1f }, Projectile.Center); + + AITimer++; + } + else if (Target is null) + { + Projectile.Center = Vector2.Lerp(Projectile.Center, Owner.Center + Projectile.rotation.ToRotationVector2() * (MirrorofKalandra.IdleDistanceFromPlayer + MirrorofKalandra.IdleDistanceFromPlayer * (MathF.Sin(Oscillation) / MirrorofKalandra.OscillationRange)), .4f); + Projectile.velocity = Vector2.Zero; + Projectile.rotation = Projectile.rotation.AngleLerp(-MathHelper.PiOver2 + MathHelper.PiOver4 / 1.5f, .15f); + Oscillation += MirrorofKalandra.OscillationSpeed; + + hasTeleported = false; + Projectile.extraUpdates = 0; + AITimer = 0f; + } + } + + public void CheckMinionExistence() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Projectile.type != ModContent.ProjectileType()) + return; + + if (Owner.dead) + ModdedOwner.KalandraMirror = false; + if (ModdedOwner.KalandraMirror) + Projectile.timeLeft = 2; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + SparkParticle sparkOnHit = new SparkParticle(Vector2.Lerp(Projectile.Center, target.Center, .8f), + (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * .01f, // It'll rotate, but due to the multiplier it won't move. + false, + 20, + Main.rand.NextFloat(1.2f, 1.8f), + Color.White); + GeneralParticleHandler.SpawnParticle(sparkOnHit); + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + float rotation = (Target is not null) ? Projectile.rotation : Projectile.rotation + MathHelper.PiOver4; + + if (CalamityConfig.Instance.Afterimages && Target is not null) + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + Color afterimageDrawColor = Color.Gray with { A = 125 } * Projectile.Opacity * (1f - i / (float)Projectile.oldPos.Length); + Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + Main.EntitySpriteDraw(texture, afterimageDrawPosition, frame, afterimageDrawColor, rotation, origin, Projectile.scale, SpriteEffects.None, 0); + } + } + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), rotation, origin, Projectile.scale, SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/Summon/MirrorofKalandraMinions/Paradoxica.png b/Projectiles/Summon/MirrorofKalandraMinions/Paradoxica.png new file mode 100644 index 0000000000..022bca20f0 Binary files /dev/null and b/Projectiles/Summon/MirrorofKalandraMinions/Paradoxica.png differ diff --git a/Projectiles/Summon/MirrorofKalandraMinions/Starforge.cs b/Projectiles/Summon/MirrorofKalandraMinions/Starforge.cs new file mode 100644 index 0000000000..72060e6fe9 --- /dev/null +++ b/Projectiles/Summon/MirrorofKalandraMinions/Starforge.cs @@ -0,0 +1,154 @@ +using System; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Particles; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions +{ + public class Starforge : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer ModdedOwner => Owner.Calamity(); + public NPC Target => Projectile.Center.MinionHoming(MirrorofKalandra.TargetDistanceDetection, Owner); + public ref float TimerToBoom => ref Projectile.ai[0]; + public ref float DrawSpin => ref Projectile.ai[1]; + public ref float Oscillation => ref Projectile.ai[2]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 3; + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 12000; + } + + public override void SetDefaults() + { + Projectile.minionSlots = 1; + Projectile.localNPCHitCooldown = MirrorofKalandra.Purple_IFrames; + Projectile.penetrate = -1; + + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 92; + Projectile.minion = true; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + } + + public override void AI() + { + CheckMinionExistence(); + + if (Main.rand.NextBool(3)) + { + MediumMistParticle mist = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(Projectile.width / 2, Projectile.height / 2), + Main.rand.NextVector2Circular(4f, 4f), + Color.DarkMagenta, + Color.Magenta, + Main.rand.NextFloat(.9f, 1.1f), + Main.rand.NextFloat(140f, 150f)); + GeneralParticleHandler.SpawnParticle(mist); + + int flavorDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 272, 0, 0, 0, default, .6f); + Main.dust[flavorDust].noGravity = true; + } + + if (Target is not null) + { + // The distance to the target plus a small number so it's not 0, it'd break calculations. + float distanceToTarget = Projectile.Distance(Target.Center) + .01f; + + // The minion will head towards it's rotation. + // If the target's close, the minion'll speed up, and viceversa, so it doesn't circle around the target doing nothing. + Projectile.velocity = Projectile.rotation.ToRotationVector2() * (MirrorofKalandra.Purple_MinRamSpeed + (12f / (distanceToTarget * .01f))); + Projectile.velocity = Vector2.Clamp(Projectile.velocity, Vector2.One * -MirrorofKalandra.Purple_MaxRamSpeed, Vector2.One * MirrorofKalandra.Purple_MaxRamSpeed); + Projectile.rotation = Projectile.rotation.AngleTowards(Projectile.AngleTo(Target.Center), .001f * distanceToTarget); + + TimerToBoom++; + } + else if (Target is null) + { + Projectile.Center = Vector2.Lerp(Projectile.Center, Owner.Center + Projectile.rotation.ToRotationVector2() * (MirrorofKalandra.IdleDistanceFromPlayer + MirrorofKalandra.IdleDistanceFromPlayer * (MathF.Sin(Oscillation) / MirrorofKalandra.OscillationRange)), .4f); + Projectile.velocity = Vector2.Zero; + Projectile.rotation = Projectile.rotation.AngleLerp(-MathHelper.PiOver2 - MathHelper.PiOver4 / 1.5f, .15f); + Oscillation += MirrorofKalandra.OscillationSpeed; + } + } + + public void CheckMinionExistence() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Projectile.type != ModContent.ProjectileType()) + return; + + if (Owner.dead) + ModdedOwner.KalandraMirror = false; + if (ModdedOwner.KalandraMirror) + Projectile.timeLeft = 2; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // If enough time has passed and an enemy is hit, boom. + if (TimerToBoom >= MirrorofKalandra.Purple_BlastFireRate && Main.myPlayer == Projectile.owner) + { + int blast = Projectile.NewProjectile(Projectile.GetSource_FromThis(), + Projectile.Center, + Vector2.Zero, + ModContent.ProjectileType(), + (int)(Projectile.damage * MirrorofKalandra.Purple_BlastDMGModifier), + Projectile.knockBack, + Owner.whoAmI); + + if (Main.projectile.IndexInRange(blast)) + Main.projectile[blast].originalDamage = (int)(Projectile.originalDamage / MirrorofKalandra.Purple_BlastDMGModifier); + + TimerToBoom = 0f; + } + + SparkParticle sparkOnHit = new SparkParticle(Vector2.Lerp(Projectile.Center, target.Center, .8f), + -Projectile.velocity * .01f, + false, + 20, + Main.rand.NextFloat(1.2f, 1.8f), + Color.Purple); + GeneralParticleHandler.SpawnParticle(sparkOnHit); + + SoundEngine.PlaySound(CommonCalamitySounds.SwiftSliceSound with { PitchVariance = .5f } with { Volume = .2f }, Projectile.Center); + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + DrawSpin -= MathHelper.ToRadians(MirrorofKalandra.Purple_SpinSpeed); + float rotation = (Target is not null) ? DrawSpin : Projectile.rotation + MathHelper.Pi - MathHelper.PiOver4; + + if (CalamityConfig.Instance.Afterimages && Target is not null) + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + Color afterimageDrawColor = Color.Purple with { A = 125 } * Projectile.Opacity * (1f - i / (float)Projectile.oldPos.Length); + Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + Main.EntitySpriteDraw(texture, afterimageDrawPosition, frame, afterimageDrawColor, rotation, origin, Projectile.scale, SpriteEffects.FlipHorizontally, 0); + } + } + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), rotation, origin, Projectile.scale, SpriteEffects.FlipHorizontally, 0); + + return false; + } + } +} diff --git a/Projectiles/Summon/MirrorofKalandraMinions/Starforge.png b/Projectiles/Summon/MirrorofKalandraMinions/Starforge.png new file mode 100644 index 0000000000..cb7a1a028a Binary files /dev/null and b/Projectiles/Summon/MirrorofKalandraMinions/Starforge.png differ diff --git a/Projectiles/Summon/MirrorofKalandraMinions/StarforgeBlast.cs b/Projectiles/Summon/MirrorofKalandraMinions/StarforgeBlast.cs new file mode 100644 index 0000000000..e23e84811f --- /dev/null +++ b/Projectiles/Summon/MirrorofKalandraMinions/StarforgeBlast.cs @@ -0,0 +1,63 @@ +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using System; + +namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions +{ + public class StarforgeBlast : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 12000; + } + + public override void SetDefaults() + { + Projectile.timeLeft = MirrorofKalandra.Purple_BlastChargeTime; + Projectile.localNPCHitCooldown = MirrorofKalandra.Purple_BlastChargeTime; + Projectile.penetrate = -1; + + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = MirrorofKalandra.Purple_BlastSize; + Projectile.ignoreWater = true; + Projectile.friendly = true; + Projectile.tileCollide = false; + } + + public override void AI() + { + GenericBloom boom = new GenericBloom(Projectile.Center, + Vector2.Zero, + Color.Lerp(Color.DarkMagenta, Color.White, MathF.Pow(Utils.GetLerpValue(MirrorofKalandra.Purple_BlastChargeTime, 0f, Projectile.timeLeft), 6)), // No Color Remap function, insert sad emote. + Utils.Remap(Projectile.timeLeft, MirrorofKalandra.Purple_BlastChargeTime, 5f, .5f, 4.2f), + MirrorofKalandra.Purple_BlastChargeTime); + GeneralParticleHandler.SpawnParticle(boom); + } + + public override void Kill(int timeLeft) + { + int dustAmount = 100; + for (int dustIndex = 0; dustIndex < dustAmount; dustIndex++) + { + float angle = MathHelper.TwoPi / dustAmount * dustIndex; + Vector2 velocity = angle.ToRotationVector2() * Main.rand.NextFloat(2f, 15f); + Dust boomDust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(MirrorofKalandra.Purple_BlastSize / 2, MirrorofKalandra.Purple_BlastSize / 2), 272, velocity); + boomDust.noGravity = true; + boomDust.velocity *= .8f; + boomDust.scale = velocity.Length() * .08f; + } + + // Electric boom sound. + SoundEngine.PlaySound(SoundID.Item94, Projectile.Center); + } + } +} diff --git a/Projectiles/Summon/MirrorofKalandraMinions/WindRipper.cs b/Projectiles/Summon/MirrorofKalandraMinions/WindRipper.cs new file mode 100644 index 0000000000..4b5e718609 --- /dev/null +++ b/Projectiles/Summon/MirrorofKalandraMinions/WindRipper.cs @@ -0,0 +1,115 @@ +using System; +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions +{ + public class WindRipper : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public Player Owner => Main.player[Projectile.owner]; + public CalamityPlayer ModdedOwner => Owner.Calamity(); + public NPC Target => Projectile.Center.MinionHoming(MirrorofKalandra.TargetDistanceDetection, Owner); + public ref float Oscillation => ref Projectile.ai[0]; + + public override void SetStaticDefaults() => Main.projFrames[Type] = 7; + + public override void SetDefaults() + { + Projectile.penetrate = -1; + + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 84; + Projectile.minion = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.friendly = true; + } + + public override void AI() + { + CheckMinionExistence(); + + Projectile.Center = Vector2.Lerp(Projectile.Center, Owner.Center + (-MathHelper.PiOver2 - MathHelper.PiOver4 * 1.5f).ToRotationVector2() * (MirrorofKalandra.IdleDistanceFromPlayer + MirrorofKalandra.IdleDistanceFromPlayer * (MathF.Sin(Oscillation) / MirrorofKalandra.OscillationRange)), .4f); + Projectile.velocity = Vector2.Zero; + Oscillation += MirrorofKalandra.OscillationSpeed; + + if (Target is not null) + { + DoAnimation(); + ShootTarget(); + + Projectile.rotation = Projectile.rotation.AngleTowards(CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, Target, MirrorofKalandra.Wind_ArrowSpeed).ToRotation(), .2f); + } + else + { + Projectile.frame = 0; + Projectile.rotation = Projectile.rotation.AngleTowards(-MathHelper.PiOver2 - MathHelper.PiOver4 * 1.5f, .2f); + } + } + + public void DoAnimation() + { + Projectile.frameCounter++; + if (Projectile.frameCounter % MirrorofKalandra.Wind_BowChargeTime == 0) + Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type]; + } + + public void ShootTarget() + { + // On the first frame where the projectile is on the firing frame animation, fire an arrow. + if (Projectile.frame == 5 && Projectile.frameCounter % MirrorofKalandra.Wind_BowChargeTime == 0 && Main.myPlayer == Projectile.owner) + { + Vector2 spawnPosition = Projectile.Center + Projectile.rotation.ToRotationVector2() * (Projectile.width / 2); + int arrow = Projectile.NewProjectile(Projectile.GetSource_FromThis(), + Projectile.Center, + CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, Target, MirrorofKalandra.Wind_ArrowSpeed), + ModContent.ProjectileType(), + Projectile.damage, + Projectile.knockBack, + Owner.whoAmI); + + if (Main.projectile.IndexInRange(arrow)) + Main.projectile[arrow].originalDamage = Projectile.originalDamage; + + SoundEngine.PlaySound(SoundID.Item5, Owner.Center); + + Projectile.netUpdate = true; + } + } + + public void CheckMinionExistence() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Projectile.type != ModContent.ProjectileType()) + return; + + if (Owner.dead) + ModdedOwner.KalandraMirror = false; + if (ModdedOwner.KalandraMirror) + Projectile.timeLeft = 2; + } + + public override bool? CanDamage() => false; + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/Summon/MirrorofKalandraMinions/WindRipper.png b/Projectiles/Summon/MirrorofKalandraMinions/WindRipper.png new file mode 100644 index 0000000000..4db4d9985b Binary files /dev/null and b/Projectiles/Summon/MirrorofKalandraMinions/WindRipper.png differ diff --git a/Projectiles/Summon/MirrorofKalandraMinions/WindRipperArrow.cs b/Projectiles/Summon/MirrorofKalandraMinions/WindRipperArrow.cs new file mode 100644 index 0000000000..83a6846b81 --- /dev/null +++ b/Projectiles/Summon/MirrorofKalandraMinions/WindRipperArrow.cs @@ -0,0 +1,69 @@ +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using CalamityMod.Particles; + +namespace CalamityMod.Projectiles.Summon.MirrorofKalandraMinions +{ + public class WindRipperArrow : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 5; + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 12000; + } + + public override void SetDefaults() + { + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 18; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + } + + public override void AI() + { + Projectile.rotation = Projectile.velocity.ToRotation(); + + if (Main.rand.NextBool(5)) + { + SparkParticle windEffect = new SparkParticle(Projectile.Center + Main.rand.NextVector2Circular(25f, 25f), + Projectile.velocity, + false, + 60, + Main.rand.NextFloat(1f, 1.2f), + Color.White); + GeneralParticleHandler.SpawnParticle(windEffect); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + + if (CalamityConfig.Instance.Afterimages) + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + Color afterimageDrawColor = Color.Gray with { A = 125 } * Projectile.Opacity * (1f - i / (float)Projectile.oldPos.Length); + Vector2 afterimageDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + Main.EntitySpriteDraw(texture, afterimageDrawPosition, frame, afterimageDrawColor, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + } + } + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + + return false; + } + } +} diff --git a/Projectiles/Summon/MirrorofKalandraMinions/WindRipperArrow.png b/Projectiles/Summon/MirrorofKalandraMinions/WindRipperArrow.png new file mode 100644 index 0000000000..5417c9d082 Binary files /dev/null and b/Projectiles/Summon/MirrorofKalandraMinions/WindRipperArrow.png differ