diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 221623cbe5..0ee7656919 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -632,8 +632,11 @@ SanctifiedSpark: { DisplayName: Sanctified Spark Tooltip: ''' - {$CommonItemTooltip.Sentry} - Summons a friendly immolator to fire holy sparks at your enemies +{$CommonItemTooltip.Sentry} +Summons a friendly immolator that will float towrds you +Immolators rapidly fire homing flares at nearby enemies, before continuing to float near you again +After firing, Immolators will fire one healing bolt at you for every 4 summon slots you have +'They might be a bit clingy, but at least they're warmth' ''' } diff --git a/Particles/HeartParticle.png b/Particles/HeartParticle.png new file mode 100644 index 0000000000..d2693e27e0 Binary files /dev/null and b/Particles/HeartParticle.png differ diff --git a/Projectiles/Summon/FlameBlast.cs b/Projectiles/Summon/FlameBlast.cs index 58ec9363b6..9dfdbe8a09 100644 --- a/Projectiles/Summon/FlameBlast.cs +++ b/Projectiles/Summon/FlameBlast.cs @@ -1,4 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -24,64 +26,50 @@ namespace CalamityMod.Projectiles.Summon { Projectile.width = Projectile.height = 6; Projectile.friendly = true; - Projectile.tileCollide = true; - Projectile.timeLeft = 180; + Projectile.tileCollide = false; + Projectile.extraUpdates = 3; + Projectile.timeLeft = 240; Projectile.DamageType = DamageClass.Summon; } public override void AI() { Player player = Main.player[Projectile.owner]; + NPC potentialTarget = Projectile.Center.MinionHoming(900f, Main.player[Projectile.owner]); + float velPower = Utils.GetLerpValue(2, 5, Projectile.velocity.Length(), true); if (count == 0f) { - SoundEngine.PlaySound(SoundID.Item73, Projectile.position); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 20; - Projectile.height = 20; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int i = 0; i < 10; i++) - { - int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 2f); - Main.dust[dust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[dust].scale = 0.5f; - Main.dust[dust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 20; j++) - { - int dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GoldCoin, 0f, 0f, 100, default, 3f); - Main.dust[dust2].noGravity = true; - Main.dust[dust2].velocity *= 5f; - dust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GoldCoin, 0f, 0f, 100, default, 2f); - Main.dust[dust2].velocity *= 2f; - } + count += 1f; } Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { - for (int k = 0; k < 5; k++) - { - int otherDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 0.75f); - Main.dust[otherDust].velocity *= 0f; - } + Particle beam = new CustomSpark(Projectile.Center, Projectile.velocity * 0.1f, "CalamityMod/Particles/SmallBloom", false, 8, 0.085f, Color.Lerp(Color.OrangeRed, Color.Goldenrod, Utils.GetLerpValue(270, 230, Projectile.timeLeft)), new Vector2(1f, (1 + 0.8f * velPower)), true, false, 0, false, false, 0.5f * velPower); + GeneralParticleHandler.SpawnParticle(beam); } - NPC potentialTarget = Projectile.Center.MinionHoming(300f, Main.player[Projectile.owner]); - if (potentialTarget != null) - Projectile.velocity = (Projectile.velocity * 20f + Projectile.SafeDirectionTo(potentialTarget.Center) * 25f) / 21f; + + if (potentialTarget != null && (Projectile.localAI[0] % 100 <= 55 || Projectile.localAI[0] < 20)) + { + Projectile.timeLeft++; // Extend liftime so it doesnt fizzle out so fast while tracking something + Projectile.velocity = (Projectile.velocity * 20f + Projectile.SafeDirectionTo(potentialTarget.Center) * 8f) / 21f; + } + else + Projectile.velocity *= Main.rand.NextFloat(0.96f, 0.97f); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); public override void OnKill(int timeLeft) { - for (int k = 0; k < 5; k++) + for (int j = 0; j < 9; j++) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.CopperCoin, Projectile.oldVelocity.X * 0f, Projectile.oldVelocity.Y * 0f); + Dust c = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + c.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.5f) * Main.rand.NextFloat(7, 15); + c.scale = Main.rand.NextFloat(0.9f, 1.1f); + c.noGravity = true; + c.color = Main.rand.NextBool() ? Color.Orange : Color.Goldenrod; + c.noLightEmittence = true; } } } diff --git a/Projectiles/Summon/ProfanedEnergy.cs b/Projectiles/Summon/ProfanedEnergy.cs index 66da00abc3..10bbde859b 100644 --- a/Projectiles/Summon/ProfanedEnergy.cs +++ b/Projectiles/Summon/ProfanedEnergy.cs @@ -1,5 +1,9 @@ using System; +using System.Collections.Generic; using CalamityMod.Dusts; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -14,6 +18,18 @@ namespace CalamityMod.Projectiles.Summon public override string Texture => "CalamityMod/NPCs/NormalNPCs/ImpiousImmolator"; private float count = 0f; + public bool flaping = false; + public NPC targeted; + public int maxTargetDistance = 500; // Since they move, the targeting distance is lower than normal + + public int maxRechargeTime = 180; + + public ref float attackTimer => ref Projectile.ai[0]; + public ref float attackCooldown => ref Projectile.ai[1]; + public int attacks = 0; + public int maxAttacks = 10; + + public int reactTimer = 0; public override void SetStaticDefaults() { @@ -36,122 +52,170 @@ namespace CalamityMod.Projectiles.Summon { Player player = Main.player[Projectile.owner]; Projectile.frameCounter++; + flaping = false; if (Projectile.frameCounter > 5) { Projectile.frame++; + if (Projectile.frame == 2) + flaping = true; Projectile.frameCounter = 0; } if (Projectile.frame > 3) { Projectile.frame = 0; } - if (count == 0f) + + if (flaping) + Projectile.velocity += -Vector2.UnitY * 4.6f; + else + Projectile.velocity += Vector2.UnitY * 0.2f; + + // Anticlump + for (int x = 0; x < Main.maxProjectiles; x++) { - SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); - for (int i = 0; i < 5; i++) + Projectile projectile = Main.projectile[x]; + if (Vector2.Distance(Projectile.Center, projectile.Center) <= 70 && projectile.active && projectile.type == Projectile.type && projectile != Projectile) { - int holy = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); - Main.dust[holy].velocity *= 3f; - Main.dust[holy].position = Projectile.Center; - if (Main.rand.NextBool()) + Projectile.velocity += Utils.DirectionFrom(Projectile.Center, projectile.Center) * 0.02f; + } + } + + float rate = Main.GlobalTimeWrappedHourly * 2; + List eColors = new List() + { + Color.Gold, + Color.Khaki + }; + + int colorIndex = (int)(rate / 2 % eColors.Count); + Color currentColor = eColors[colorIndex]; + Color nextColor = eColors[(colorIndex + 1) % eColors.Count]; + Color usedColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f); + + Lighting.AddLight(Projectile.Center, usedColor.ToVector3() * 0.8f); + + if (targeted == null) // Find target or move closer to the player + { + Vector2 moveDir = Utils.DirectionTo(Projectile.Center, player.Center); + // If there's no target and the player isnt too close, flap closer them a bit (woah non stationary sentry crazy) + if (flaping && Utils.Distance(player.Center, Projectile.Center) > 300) + { + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact with { Volume = 0.3f, Pitch = 0.8f }, Projectile.Center); + Projectile.velocity += (moveDir * Main.rand.NextFloat(3f, 5f)).RotatedByRandom(0.4f); + + for (int j = 0; j < 8; j++) { - Main.dust[holy].scale = 0.5f; - Main.dust[holy].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Dust c = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(35, 35), ModContent.DustType()); + c.velocity = -Projectile.velocity.SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(3, 7); + c.scale = Main.rand.NextFloat(0.5f, 0.7f); + c.noGravity = true; + c.color = Color.Orchid; + c.noLightEmittence = true; } } - for (int j = 0; j < 10; j++) + + if (reactTimer < 600) { - int fire = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, DustID.GoldCoin, 0f, 0f, 100, default, 3f); - Main.dust[fire].noGravity = true; - Main.dust[fire].velocity *= 5f; - Main.dust[fire].position = Projectile.Center; - fire = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, DustID.GoldCoin, 0f, 0f, 100, default, 2f); - Main.dust[fire].velocity *= 2f; - Main.dust[fire].position = Projectile.Center; + if (Utils.Distance(player.Center, Projectile.Center) < 120) + reactTimer++; + } + else + { + SoundStyle happy = new("CalamityMod/Sounds/Item/SanctifiedSparkHappy"); + SoundEngine.PlaySound(happy with { Volume = 0.5f, PitchVariance = 0.3f }, Projectile.Center); + for (int i = 0; i < 3; i++) + { + Particle spark = new CustomSpark(Projectile.Center, (-Vector2.UnitY * Main.rand.NextFloat(3f, 5f)).RotatedByRandom(0.6f), "CalamityMod/Particles/HeartParticle", false, 75, Main.rand.NextFloat(1.3f, 1.8f), Color.Lerp(Color.Goldenrod, Color.OrangeRed, i * 0.5f), Vector2.One, true, true, 0, false, false); + GeneralParticleHandler.SpawnParticle(spark); + } + reactTimer = Main.rand.Next(0, 120 + 1); + } + + if (player.HasMinionAttackTargetNPC) + { + targeted = Main.npc[player.MinionAttackTargetNPC]; + if (!targeted.CanBeChasedBy(Projectile, false) || Utils.Distance(Projectile.Center, targeted.Center) > maxTargetDistance) + targeted = null; + } + else + { + targeted = Projectile.Center.ClosestNPCAt(maxTargetDistance); + } + + Projectile.spriteDirection = Math.Sign(-moveDir.X); + Projectile.rotation = Utils.AngleLerp(Projectile.rotation, 0, 0.05f); + } + if (targeted != null && ((Utils.Distance(Projectile.Center, targeted.Center) > maxTargetDistance) || attackCooldown > 0 || targeted.active == false || targeted.life <= 0)) // Reset targeting if they leave aggro range or are on attack cooldown + { + targeted = null; + } + if (targeted != null) // Attacks + { + reactTimer = Main.rand.Next(0, 120 + 1); + if (Projectile.owner == Main.myPlayer) + { + Vector2 shootVel = Utils.DirectionTo(Projectile.Center, targeted.Center) * 8; + Projectile.spriteDirection = Math.Sign(-shootVel.X); + if (attackTimer <= 0) + { + SoundEngine.PlaySound(SoundID.Item73, Projectile.Center); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (shootVel * Main.rand.NextFloat(0.8f, 1.2f)).RotatedBy(0.75f * (attacks % 2 == 0 ? -1 : 1)).RotatedByRandom(0.4f), ModContent.ProjectileType(), Projectile.damage, 0, Projectile.owner); + + Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Goldenrod, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, Main.rand.NextFloat(0.75f, 1f), 15); + GeneralParticleHandler.SpawnParticle(orb2); + + attackTimer = 8; + attacks++; + } + else + attackTimer--; + + if (attacks >= 18) + { + attackCooldown = maxRechargeTime; + attacks = 0; + } + + Projectile.rotation = Utils.AngleLerp(Projectile.rotation, shootVel.ToRotation() + (Projectile.spriteDirection == -1 ? 0 : MathHelper.ToRadians(180f)), 0.07f); + } + } + if (attackTimer > 0) + attackTimer--; + if (attackCooldown > 0) + { + int healShots = (int)(player.maxMinions / 4); + if (healShots != 0 && attackCooldown != maxRechargeTime && (attackCooldown % (maxRechargeTime / (healShots + 1)) == 0)) + { + Vector2 vel = ((Projectile.Center - player.Center) - player.velocity * 10).SafeNormalize(Vector2.UnitX) * -10; + Projectile healStar = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, vel, ModContent.ProjectileType(), 0, Projectile.knockBack, Projectile.owner, 0, 10, 5); + healStar.extraUpdates = 2; + SoundStyle fireHeal = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianDash"); + SoundEngine.PlaySound(fireHeal with { Volume = 0.7f, Pitch = 0.3f }, Projectile.Center); + + Particle orb2 = new CustomPulse(Projectile.Center, Vector2.Zero, new Color(54, 209, 54), "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 1.3f, 24); + GeneralParticleHandler.SpawnParticle(orb2); + } + attackCooldown--; + } + + Projectile.velocity *= 0.97f; + + if (count == 0f) // Spawn effects + { + reactTimer += Main.rand.Next(0, 120 + 1); + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + for (int i = 0; i < 20; i++) + { + Dust c = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType()); + c.velocity = (MathHelper.TwoPi * i / 20f).ToRotationVector2() * 15.5f * (i % 2 == 0 ? 0.88f : 1f); + c.scale = Main.rand.NextFloat(1.3f, 1.6f) * 0.8f * (i % 2 == 0 ? 2.2f : 1.8f); + c.noGravity = true; + c.color = Color.Goldenrod; + c.noLightEmittence = true; } count += 1f; } - if (Projectile.owner == Main.myPlayer) - { - if (Projectile.ai[0] != 0f) - { - Projectile.ai[0] -= 1f; - return; - } - bool canAttack = false; - float projX = Projectile.Center.X; - float projY = Projectile.Center.Y; - float attackDistance = 1000f; - int target = 0; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(Projectile, false)) - { - float targetX = npc.Center.X; - float targetY = npc.Center.Y; - float targetDist = Math.Abs(Projectile.Center.X - targetX) + Math.Abs(Projectile.Center.Y - targetY); - if (targetDist < attackDistance && Collision.CanHit(Projectile.Center, Projectile.width, Projectile.height, npc.Center, npc.width, npc.height)) - { - projX = targetX; - projY = targetY; - canAttack = true; - target = npc.whoAmI; - } - } - } - if (!canAttack) - { - foreach (NPC n in Main.ActiveNPCs) - { - if (n.CanBeChasedBy(Projectile, false)) - { - float npcX = n.position.X + (float)(n.width / 2); - float npcY = n.position.Y + (float)(n.height / 2); - float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY); - if (npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height)) - { - attackDistance = npcDist; - projX = npcX; - projY = npcY; - canAttack = true; - target = n.whoAmI; - } - } - } - } - if (canAttack) - { - float projXStore = projX; - float projYStore = projY; - projX -= Projectile.Center.X; - projY -= Projectile.Center.Y; - if (projX < 0f) - { - Projectile.spriteDirection = 1; - } - else - { - Projectile.spriteDirection = -1; - } - int projectileType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.ProjectileType(), - ModContent.ProjectileType() - }); - float speed = 25f; - Vector2 fireDirection = Projectile.Center; - float fireXVel = projXStore - fireDirection.X; - float fireYVel = projYStore - fireDirection.Y; - float fireVelocity = (float)Math.Sqrt((double)(fireXVel * fireXVel + fireYVel * fireYVel)); - fireVelocity = speed / fireVelocity; - fireXVel *= fireVelocity; - fireYVel *= fireVelocity; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, fireXVel, fireYVel, projectileType, Projectile.damage, Projectile.knockBack, Projectile.owner, (float)target, 0f); - - Projectile.ai[0] = 16f; - } - } + } public override bool? CanDamage() => false; diff --git a/Sounds/Item/SanctifiedSparkHappy.ogg b/Sounds/Item/SanctifiedSparkHappy.ogg new file mode 100644 index 0000000000..fad4b549d1 Binary files /dev/null and b/Sounds/Item/SanctifiedSparkHappy.ogg differ