diff --git a/Dusts/RosePiece.cs b/Dusts/RosePiece.cs new file mode 100644 index 0000000000..11742dd643 --- /dev/null +++ b/Dusts/RosePiece.cs @@ -0,0 +1,41 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class RosePiece : ModDust + { + public override void OnSpawn(Dust dust) + { + dust.color = default; + dust.rotation = Main.rand.NextFloat(MathHelper.TwoPi); + } + + public override bool Update(Dust dust) + { + dust.rotation += MathHelper.ToRadians(1.56f); + + if (!dust.noGravity) + dust.velocity.Y = MathHelper.Clamp(dust.velocity.Y + 0.15f, -1.8f, 2.5f); + + Vector2 velocity = Vector2.UnitY.RotatedBy(dust.rotation) * new Vector2(2f, 0.5f); + + // Adjust the move angle if a tile has been hit. + if (velocity != Collision.TileCollision(dust.position, velocity, (int)(dust.scale * 4f), (int)(dust.scale * 4f))) + dust.rotation = -1f; + + dust.position += velocity + dust.velocity; + + // Fade away. + dust.scale = MathHelper.Clamp(dust.scale - 0.01f, 0f, 4f) * 0.99f; + if (dust.scale < 0.4f) + dust.active = false; + + return false; + } + + public override Color? GetAlpha(Dust dust, Color lightColor) => lightColor; + } +} \ No newline at end of file diff --git a/Dusts/RosePiece.png b/Dusts/RosePiece.png new file mode 100644 index 0000000000..9f38d90dab Binary files /dev/null and b/Dusts/RosePiece.png differ diff --git a/Items/Weapons/Magic/ThePrince.cs b/Items/Weapons/Magic/ThePrince.cs new file mode 100644 index 0000000000..2bf9eb0da7 --- /dev/null +++ b/Items/Weapons/Magic/ThePrince.cs @@ -0,0 +1,68 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Magic +{ + public class ThePrince : ModItem + { + public const int FlameSplitCount = 6; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Prince"); + Tooltip.SetDefault($"Casts a holy fireball that explodes into {FlameSplitCount} flames\n" + + "So you're telling me that the prince exploded, and then turned into a flower?\n" + + "-Dain, the sailor druid"); + Item.staff[item.type] = true; + } + + public override void SetDefaults() + { + item.damage = 155; + item.knockBack = 4.25f; + item.shootSpeed = 23.5f; + item.magic = true; + item.noMelee = true; + item.mana = 12; + item.width = 102; + item.height = 112; + item.useTime = item.useAnimation = 21; + item.useStyle = ItemUseStyleID.HoldingOut; + item.autoReuse = true; + item.UseSound = SoundID.DD2_FlameburstTowerShot; + item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } + + public override Vector2? HoldoutOrigin() + { + return new Vector2(20f, 20f); + } + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Vector2 velocity = new Vector2(speedX, speedY); + Vector2 flameSpawnPosition = player.RotatedRelativePoint(player.MountedCenter, true); + flameSpawnPosition += velocity.SafeNormalize(Vector2.Zero) * 105f; + Projectile.NewProjectile(flameSpawnPosition, velocity, type, damage, knockBack, player.whoAmI); + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 7); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Magic/ThePrince.png b/Items/Weapons/Magic/ThePrince.png new file mode 100644 index 0000000000..c61962423b Binary files /dev/null and b/Items/Weapons/Magic/ThePrince.png differ diff --git a/Projectiles/Magic/PrinceFlameLarge.cs b/Projectiles/Magic/PrinceFlameLarge.cs new file mode 100644 index 0000000000..225ba88127 --- /dev/null +++ b/Projectiles/Magic/PrinceFlameLarge.cs @@ -0,0 +1,114 @@ +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class PrinceFlameLarge : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public const int Lifetime = 60; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Holy Fireball"); + Main.projFrames[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 40; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.timeLeft = Lifetime; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 11; + projectile.magic = true; + } + + public override void AI() + { + // Create rose petals. + if (projectile.localAI[0] == 0f) + { + for (int i = 0; i < 10; i++) + { + Dust rose = Dust.NewDustPerfect(projectile.Center, ModContent.DustType()); + rose.velocity += projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(0.61f) * 2.5f; + rose.velocity.Y += Main.rand.NextFloat(-2.4f, 1.6f); + rose.velocity *= 0.4f; + rose.scale = Main.rand.NextFloat(1.2f, 1.7f); + rose.noGravity = Main.rand.NextBool(); + } + projectile.localAI[0] = 1f; + } + + // Dissipate at the end of the projectile's lifetime. + if (projectile.timeLeft < 26f) + { + projectile.rotation = projectile.rotation.AngleLerp(0f, 0.15f); + projectile.frame = (int)Math.Round(MathHelper.Lerp(4f, 7f, Utils.InverseLerp(26f, 0f, projectile.timeLeft, true))); + projectile.velocity *= 0.95f; + return; + } + + // Create bursts of fire dust. + if (Time % 8f == 7f) + { + for (int i = 0; i < 12; i++) + { + Vector2 dustSpawnOffset = Vector2.UnitX * -projectile.width / 2f; + dustSpawnOffset += -Vector2.UnitY.RotatedBy(i * MathHelper.TwoPi / 12f) * new Vector2(8f, 16f); + dustSpawnOffset = dustSpawnOffset.RotatedBy(projectile.rotation - MathHelper.PiOver2); + + Dust holyFire = Dust.NewDustDirect(projectile.Center, 0, 0, (int)CalamityDusts.ProfanedFire, 0f, 0f, 160, default, 1f); + holyFire.scale = 1.1f; + holyFire.noGravity = true; + holyFire.position = projectile.Center + dustSpawnOffset; + holyFire.velocity = projectile.velocity * 0.1f; + holyFire.velocity = (projectile.Center - projectile.velocity * 3f - holyFire.position).SafeNormalize(Vector2.Zero) * 1.25f; + } + } + + Dust fire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.ProfanedFire); + fire.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 6f); + fire.scale *= Main.rand.NextFloat(1.15f, 1.7f); + fire.noGravity = Main.rand.NextBool(); + + Time++; + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + projectile.frameCounter++; + projectile.frame = projectile.frameCounter / 5 % 4; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor = Color.Lerp(lightColor, Color.White, 0.8f); + lightColor.A /= 4; + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + + public override void Kill(int timeLeft) + { + if (Main.myPlayer != projectile.owner) + return; + + int damage = (int)(projectile.damage * 0.66f); + float kb = projectile.knockBack * 0.4f; + for (int i = 0; i < ThePrince.FlameSplitCount; i++) + { + Vector2 shootVelocity = (MathHelper.TwoPi * i / ThePrince.FlameSplitCount).ToRotationVector2() * 8f; + Vector2 flameSpawnPosition = projectile.Center + shootVelocity; + Projectile.NewProjectile(flameSpawnPosition, shootVelocity, ModContent.ProjectileType(), damage, kb, projectile.owner); + } + } + } +} diff --git a/Projectiles/Magic/PrinceFlameLarge.png b/Projectiles/Magic/PrinceFlameLarge.png new file mode 100644 index 0000000000..d64d14a9a5 Binary files /dev/null and b/Projectiles/Magic/PrinceFlameLarge.png differ diff --git a/Projectiles/Magic/PrinceFlameSmall.cs b/Projectiles/Magic/PrinceFlameSmall.cs new file mode 100644 index 0000000000..46c7fb79d6 --- /dev/null +++ b/Projectiles/Magic/PrinceFlameSmall.cs @@ -0,0 +1,53 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class PrinceFlameSmall : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public const int AttackDelay = 12; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Holy Fire"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 16; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.timeLeft = 300; + projectile.penetrate = 1; + projectile.magic = true; + } + + public override void AI() + { + Time++; + projectile.frameCounter++; + projectile.frame = projectile.frameCounter / 5 % Main.projFrames[projectile.type]; + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + + if (Time > AttackDelay) + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 700f, 14f, 32f); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor = Color.Lerp(lightColor, Color.White, 0.8f); + lightColor.A /= 3; + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + + public override bool CanDamage() => Time > AttackDelay; + } +} diff --git a/Projectiles/Magic/PrinceFlameSmall.png b/Projectiles/Magic/PrinceFlameSmall.png new file mode 100644 index 0000000000..4d42e52100 Binary files /dev/null and b/Projectiles/Magic/PrinceFlameSmall.png differ