From 90a7cbe37dbc2e358b58d9ebffbaadbed5787dc0 Mon Sep 17 00:00:00 2001 From: DominicKarma42 <51094361+DominicKarma@users.noreply.github.com> Date: Sat, 18 Apr 2020 20:09:36 -0500 Subject: [PATCH] Relic of Convergence --- Items/RelicOfConvergence.cs | 37 +++++ Items/RelicOfConvergence.png | Bin 0 -> 914 bytes ModSupport/WeakReferenceSupport.cs | 3 +- .../ProfanedGuardianBoss3.cs | 6 + .../Typeless/RelicOfConvergenceCrystal.cs | 141 ++++++++++++++++++ .../Typeless/RelicOfConvergenceCrystal.png | Bin 0 -> 914 bytes 6 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 Items/RelicOfConvergence.cs create mode 100644 Items/RelicOfConvergence.png create mode 100644 Projectiles/Typeless/RelicOfConvergenceCrystal.cs create mode 100644 Projectiles/Typeless/RelicOfConvergenceCrystal.png diff --git a/Items/RelicOfConvergence.cs b/Items/RelicOfConvergence.cs new file mode 100644 index 0000000000..7eda12625c --- /dev/null +++ b/Items/RelicOfConvergence.cs @@ -0,0 +1,37 @@ +using CalamityMod.Projectiles.Typeless; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items +{ + public class RelicOfConvergence : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Relic of Convergence"); + Tooltip.SetDefault("Creates a profaned crystal that charges power\n" + + "Holding out the crystal slows the player down\n" + + "At the end of its life, the crystal heals the player"); + } + + public override void SetDefaults() + { + item.width = 32; + item.height = 46; + item.useTime = item.useAnimation = 25; + item.reuseDelay = 15; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = SoundID.DD2_DarkMageCastHeal; + item.noMelee = true; + item.noUseGraphic = true; + item.channel = true; + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + item.shoot = ModContent.ProjectileType(); + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + } +} diff --git a/Items/RelicOfConvergence.png b/Items/RelicOfConvergence.png new file mode 100644 index 0000000000000000000000000000000000000000..4b1274b53b8b667af371cb14dbe1ee49b783cba8 GIT binary patch literal 914 zcmV;D18w|?P)Px&Oi4sRR9J=8m`zAjQ5462PXtZJ92G^yu~8#33XNPThA_}Vf)u1$gcY<2D%!PZ zkrYMi3S3x3wuvxQNEd}58d5NYVw8kmX^oNQM^0uCz825Zc<;O!6`^_kSMT1rA9H^9 z+;h*p2AcNddF0bvTc4VgXaIZ(CIfKHR{_A#_@dHIRK7RM0O))B6@a$hX1iv@+1CC; z#jn?3Uw#e%gA-FGKz4@L0C@0x$OH&HuD9)1d$~)<7}3UeE`fAck^v#hg+$NjiV0A6 zsB%LS94NN>c?uc;xZT{K{O%kA;{B;fi2%$7mlVr4s?I()0Ik=309?2`7S$JGPe3fs zbh`kUo)6ku-ZPp4K*xz?0It3o1)#HUKLFL`^HC?-nPZVXU$6Q?>~lwvSYDKy=8QP7?(JA4 z`&LwyZsm}&rVKe(); int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemID.GreaterHealingPotion }; + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemID.GreaterHealingPotion }; List collection = new List() { ItemType(), ItemType(), ItemType() }; string instructions = $"Use a [i:{summon}] in the Hallow or Underworld Biomes"; string despawn = CalamityUtils.ColorMessage("The guardians must protect their goddess at all costs.", new Color(0xFF, 0xA5, 0x00)); diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs index 4a0af28aab..7dab0178ef 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; +using CalamityMod.Items; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -295,6 +296,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians return true; } + public override void NPCLoot() + { + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + } + public override void BossLoot(ref string name, ref int potionType) { name = "A Profaned Guardian"; diff --git a/Projectiles/Typeless/RelicOfConvergenceCrystal.cs b/Projectiles/Typeless/RelicOfConvergenceCrystal.cs new file mode 100644 index 0000000000..3d773bd0f9 --- /dev/null +++ b/Projectiles/Typeless/RelicOfConvergenceCrystal.cs @@ -0,0 +1,141 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class RelicOfConvergenceCrystal : ModProjectile + { + public const int SoundInterval = 15; + public const int TotalCrystalsToDraw = 3; + public const int CrystalsDrawTime = 90; + public const float MaxCrystalOffsetRadius = 80f; + public const float MaxDustOffsetRadius = 70f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Relic of Convergence"); + } + + public override void SetDefaults() + { + projectile.width = 32; + projectile.height = 46; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 240; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + if (!player.channel) + { + projectile.Kill(); + return; + } + // Restrict player movement (as a penalty). + player.velocity.X = MathHelper.Clamp(player.velocity.X, -5f, 5f); + if (player.velocity.Y < 0f) + { + player.velocity.Y = MathHelper.Clamp(player.velocity.Y, -6f, 0f); + } + UpdatePlayerVisuals(player); + // Make a constant "magical" sound. + if (projectile.soundDelay <= 0) + { + Main.PlaySound(SoundID.Item4, projectile.Center); + projectile.soundDelay = SoundInterval; + } + projectile.ai[0]++; + // Make a sound when fully charged. + if (projectile.ai[0] == CrystalsDrawTime) + { + Main.PlaySound(SoundID.DD2_DarkMageHealImpact, projectile.Center); + } + // Create a circle of dust. The circle expands outward at first until it reaches its "destination" radius. + // Once the circle is at its maximum size, some of the dust moves inward. + if (projectile.ai[0] >= CrystalsDrawTime) + { + GeneratePassiveDust(player); + } + if (projectile.timeLeft == 1) + { + for (int i = 0; i < 45; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.ProfanedFire); + dust.velocity = Utils.NextVector2Circular(Main.rand, 28f, 28f); + dust.fadeIn = Main.rand.NextFloat(3f, 4f); + dust.noGravity = true; + } + player.HealEffect(35, false); + player.statLife += 35; + if (player.statLife > player.statLifeMax2) + { + player.statLife = player.statLifeMax2; + } + Main.PlaySound(SoundID.DD2_DarkMageHealImpact, projectile.Center); + } + } + public void UpdatePlayerVisuals(Player player) + { + projectile.Center = player.Center + Vector2.UnitX * 15f * player.direction; + + // The crystal is a holdout projectile, so change the player's variables to reflect that + player.heldProj = projectile.whoAmI; + player.itemTime = 2; + player.itemAnimation = 2; + } + + public void GeneratePassiveDust(Player player) + { + float radius = 45f; + if (projectile.ai[0] < CrystalsDrawTime + 30f) + { + radius = MathHelper.Lerp(0f, 45f, (projectile.ai[0] - CrystalsDrawTime) / 30f); + } + for (float angle = 0f; angle <= MathHelper.TwoPi; angle += MathHelper.ToRadians(Main.rand.NextFloat(6f, 8f))) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + angle.ToRotationVector2() * radius, (int)CalamityDusts.ProfanedFire); + dust.position = projectile.Center + angle.ToRotationVector2() * radius; + dust.scale = Main.rand.NextFloat(0.8f, 1.1f); + dust.noGravity = true; + dust.velocity = player.velocity; + if (Main.rand.NextBool(15) || projectile.timeLeft == 1) + { + dust.velocity = projectile.DirectionFrom(dust.position) * Main.rand.NextFloat(4f, 5f); + if (projectile.timeLeft == 1) + dust.velocity *= 1.7f; + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.ai[0] >= CrystalsDrawTime) + return true; + float opacity = projectile.ai[0] / CrystalsDrawTime; + Texture2D crystalTexture = ModContent.GetTexture(Texture); + for (int i = 0; i < TotalCrystalsToDraw; i++) + { + float angle = MathHelper.TwoPi / TotalCrystalsToDraw * i + projectile.ai[0] / 10f; + float radius = MathHelper.Lerp(MaxCrystalOffsetRadius, 0f, projectile.ai[0] / CrystalsDrawTime); + Vector2 drawPositionOffset = angle.ToRotationVector2() * radius; + Vector2 drawPosition = projectile.Center + drawPositionOffset; + spriteBatch.Draw(crystalTexture, + drawPosition - Main.screenPosition, + null, + Color.White * opacity, + projectile.rotation, + projectile.Size * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + } + return false; + } + } +} diff --git a/Projectiles/Typeless/RelicOfConvergenceCrystal.png b/Projectiles/Typeless/RelicOfConvergenceCrystal.png new file mode 100644 index 0000000000000000000000000000000000000000..4b1274b53b8b667af371cb14dbe1ee49b783cba8 GIT binary patch literal 914 zcmV;D18w|?P)Px&Oi4sRR9J=8m`zAjQ5462PXtZJ92G^yu~8#33XNPThA_}Vf)u1$gcY<2D%!PZ zkrYMi3S3x3wuvxQNEd}58d5NYVw8kmX^oNQM^0uCz825Zc<;O!6`^_kSMT1rA9H^9 z+;h*p2AcNddF0bvTc4VgXaIZ(CIfKHR{_A#_@dHIRK7RM0O))B6@a$hX1iv@+1CC; z#jn?3Uw#e%gA-FGKz4@L0C@0x$OH&HuD9)1d$~)<7}3UeE`fAck^v#hg+$NjiV0A6 zsB%LS94NN>c?uc;xZT{K{O%kA;{B;fi2%$7mlVr4s?I()0Ik=309?2`7S$JGPe3fs zbh`kUo)6ku-ZPp4K*xz?0It3o1)#HUKLFL`^HC?-nPZVXU$6Q?>~lwvSYDKy=8QP7?(JA4 z`&LwyZsm}&rVKe