From ac58cf289a6fb74efcb3a5cfa9009cdca1ae67c7 Mon Sep 17 00:00:00 2001 From: IbanPlay <56191483+IbanPlay@users.noreply.github.com> Date: Mon, 10 Jan 2022 05:52:58 +0100 Subject: [PATCH] Started work on the hallow attunement and gn --- Items/Weapons/Melee/TrueBiomeBlade.cs | 40 +++--- .../Melee/MendedBiomeBladeProjectiles.cs | 125 ++++++++++++++++++ .../Melee/MendedBiomeBlade_HeavensMight.png | Bin 0 -> 784 bytes 3 files changed, 150 insertions(+), 15 deletions(-) create mode 100644 Projectiles/Melee/MendedBiomeBlade_HeavensMight.png diff --git a/Items/Weapons/Melee/TrueBiomeBlade.cs b/Items/Weapons/Melee/TrueBiomeBlade.cs index a52521efc3..ff7a67e074 100644 --- a/Items/Weapons/Melee/TrueBiomeBlade.cs +++ b/Items/Weapons/Melee/TrueBiomeBlade.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee { public class TrueBiomeBlade : ModItem { - public enum Attunement : byte { Default, Hot, Cold, Tropical, Evil, Holy, HolyStar, Marine } + public enum Attunement : byte { Default, Hot, Cold, Tropical, Evil, Holy, Astral, Marine } public Attunement? mainAttunement = null; public Attunement? secondaryAttunement = null; public int Combo = 0; @@ -124,13 +124,13 @@ namespace CalamityMod.Items.Weapons.Melee break; case Attunement.Holy: AttunementInfo.name = "Heaven's Might"; - AttunementInfo.function_description = "Hold LMB to charge up a heaven-piercing sword thrust, and release to unleash the devastating blow"; - AttunementInfo.function_extra = "Striking the ground will create an impact so powerful, massive fragments of crystal will rise up from the earth"; + AttunementInfo.function_description = "Hold LMB to swing the sword around you, powering up as it spins"; + AttunementInfo.function_extra = "Releasing LMB will throw the sword in front of you, flying a short distance away before coming back"; AttunementInfo.color = new Color(220, 143, 255); break; - case Attunement.HolyStar: - AttunementInfo.name = "Heaven's Abhorrence"; - AttunementInfo.function_description = "Hold LMB to charge up a star-ravaging sword thrust, and release to unleash the devastating blow"; + case Attunement.Astral: + AttunementInfo.name = "The One Beyond's Abhorrence"; + AttunementInfo.function_description = "Hold LMB to charge up a star-piercing sword thrust, and release to unleash the devastating blow"; AttunementInfo.function_extra = "Striking the ground will create an impact so powerful, massive otherwordly monoliths will rise up from the earth"; AttunementInfo.color = new Color(136, 133, 23); break; @@ -255,10 +255,9 @@ namespace CalamityMod.Items.Weapons.Melee player.Calamity().rightClickListener = true; - if (player.velocity.Y == 0) //reset the amount of lunges on ground contact, but also set the power lunge counter back to zero + if (player.velocity.Y == 0) //reset the amount of lunges on ground contact { StoredLunges = 2; - PowerLungeCounter = 0; } //Change the swords function based on its attunement @@ -322,7 +321,18 @@ namespace CalamityMod.Items.Weapons.Melee Combo = 0; break; case Attunement.Holy: - case Attunement.HolyStar: + item.channel = true; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.shoot = ProjectileType(); + item.shootSpeed = 12f; + item.UseSound = null; + item.noMelee = true; + + Combo = 0; + PowerLungeCounter = 0; + break; + case Attunement.Astral: item.channel = true; item.noUseGraphic = true; item.useStyle = ItemUseStyleID.Stabbing; @@ -379,7 +389,7 @@ namespace CalamityMod.Items.Weapons.Melee public override bool CanUseItem(Player player) { return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && - (n.type == ProjectileType() || n.type == ProjectileType() || n.type == ProjectileType())); // || n.type == ProjectileType() + (n.type == ProjectileType() || n.type == ProjectileType() || n.type == ProjectileType() || n.type == ProjectileType())); // || n.type == ProjectileType() } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) @@ -435,9 +445,8 @@ namespace CalamityMod.Items.Weapons.Melee StoredLunges = 0; return false; - case Attunement.Holy: - case Attunement.HolyStar: - float astralVariant = mainAttunement == Attunement.HolyStar ? 1f : 0f; + case Attunement.Astral: + float astralVariant = mainAttunement == Attunement.Astral ? 1f : 0f; // Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileType(), damage * 2, knockBack, player.whoAmI, astralVariant); return false; @@ -446,6 +455,7 @@ namespace CalamityMod.Items.Weapons.Melee } } + //This is only used for the purity sigil effect of the default attunement public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit) { foreach (Projectile proj in Main.projectile) @@ -502,7 +512,7 @@ namespace CalamityMod.Items.Weapons.Melee BiomeEnergyParticles.CenterColor = new Color(195, 42, 200); break; case Attunement.Holy: - case Attunement.HolyStar: + case Attunement.Astral: BiomeEnergyParticles.EdgeColor = new Color(62, 55, 110); BiomeEnergyParticles.CenterColor = new Color(255, 143, 255); break; @@ -643,7 +653,7 @@ namespace CalamityMod.Items.Weapons.Melee if (holy) attunement = Attunement.Holy; if (astral) - attunement = Attunement.HolyStar; + attunement = Attunement.Astral; if (marine) attunement = Attunement.Marine; diff --git a/Projectiles/Melee/MendedBiomeBladeProjectiles.cs b/Projectiles/Melee/MendedBiomeBladeProjectiles.cs index 66b76ffe3c..437557acd4 100644 --- a/Projectiles/Melee/MendedBiomeBladeProjectiles.cs +++ b/Projectiles/Melee/MendedBiomeBladeProjectiles.cs @@ -1528,4 +1528,129 @@ namespace CalamityMod.Projectiles.Melee } } + + public class HeavensMight : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Melee/MendedBiomeBlade_HeavensMight"; + private bool initialized = false; + Vector2 direction = Vector2.Zero; + public ref float CurrentState => ref projectile.ai[0]; + public Player Owner => Main.player[projectile.owner]; + private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; + public const float throwOutTime = 40f; + public const float throwOutDistance = 240f; + public const float maxEmpowerment = 1.7f; + public float Empowerment => (projectile.scale - 1f) / (maxEmpowerment - 1f); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Heaven's Might"); + } + public override void SetDefaults() + { + projectile.melee = true; + projectile.width = projectile.height = 74; + projectile.tileCollide = false; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 16; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float collisionPoint = 0f; + float bladeLenght = 100 * projectile.scale; + float bladeWidth = 20 * projectile.scale; + + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Owner.Center, Owner.Center + (direction * bladeLenght), bladeWidth, ref collisionPoint); + } + + public override void AI() + { + if (!initialized) //Initialization. Here its litterally just playing a sound tho lmfao + { + Main.PlaySound(SoundID.Item90, projectile.Center); + direction = Owner.DirectionTo(Main.MouseWorld); + direction.Normalize(); + initialized = true; + } + + if (!OwnerCanShoot) + { + if (CurrentState == 2f) + { + projectile.Kill(); + return; + } + + else if (CurrentState == 0f) + { + CurrentState = 1f; + direction = Owner.DirectionTo(Main.MouseWorld); + } + } + + if (CurrentState == 0f) + { + //Manage position and rotation + projectile.scale *= 1.01f; + if (projectile.scale > maxEmpowerment) + projectile.scale = maxEmpowerment; + + direction = direction.RotatedBy((Empowerment) * MathHelper.PiOver4 * 0.25); + projectile.rotation = direction.ToRotation(); + projectile.Center = Owner.Center + (direction * projectile.scale * 10); + projectile.timeLeft = (int)throwOutTime + 1; + } + + if (CurrentState == 1f) + { + projectile.Center = Owner.Center + (direction * projectile.scale * 10) + ( direction * throwOutDistance * (float)Math.Sin(projectile.timeLeft / throwOutTime * MathHelper.Pi)); + } + + //Make the owner look like theyre holding the sword bla bla + Owner.heldProj = projectile.whoAmI; + Owner.direction = Math.Sign(direction.X); + Owner.itemRotation = direction.ToRotation(); + if (Owner.direction != 1) + { + Owner.itemRotation -= 3.14f; + } + Owner.itemRotation = MathHelper.WrapAngle(Owner.itemRotation); + Owner.itemTime = 2; + Owner.itemAnimation = 2; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D handle = GetTexture("CalamityMod/Items/Weapons/Melee/TrueBiomeBlade"); + Texture2D blade = GetTexture("CalamityMod/Projectiles/Melee/MendedBiomeBlade_HeavensMight"); + + float drawAngle = direction.ToRotation(); + float drawRotation = drawAngle + MathHelper.PiOver4; + + Vector2 drawOrigin = new Vector2(0f, handle.Height); + Vector2 drawOffset = projectile.Center - Main.screenPosition; + + spriteBatch.Draw(handle, drawOffset, null, lightColor, drawRotation, drawOrigin, projectile.scale, 0f, 0f); + + //Turn on additive blending + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + //Update the parameters + drawOrigin = new Vector2(0f, blade.Height); + + spriteBatch.Draw(blade, drawOffset, null, Color.Lerp(Color.White, lightColor, 0.5f) * 0.9f, drawRotation, drawOrigin, projectile.scale, 0f, 0f); + + //Back to normal + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + return false; + } + + } } + diff --git a/Projectiles/Melee/MendedBiomeBlade_HeavensMight.png b/Projectiles/Melee/MendedBiomeBlade_HeavensMight.png new file mode 100644 index 0000000000000000000000000000000000000000..3e41ca145a0bc3f8a351aaf35b205ae8686898a5 GIT binary patch literal 784 zcmV+r1MmEaP)Px%%1J~)RCt{2nlY=>P#A{a)Fk)npU_DZ1jXqhs7nzPMO~b3{Q**N7D3zu7r{YX z<%%v&6~RHBii491ii3jpPk4K4(m0&+_1e?q=1ZFA+lTigU+Q7Sd3Sir z9ZHJ4zrEe@0H9S?L932mcL9rHUXxsCl#-P*s%(=48l_}qjCy_i1pwgha0CDdqNEg) z1RAAe>5Y1R<`n>7Fo*#F>o$|T#F*vB<%mV2lq{`LPcHWW0E3-ah7tfsS{?u(@{Lj9 z(98$B=5ErDGJPd=-Y8?SUjG0)=757iRlv93~O(9CeBZzlr-L`Tlf0_if7WaK{lIq zC)Xuj>&^AZc67kVzkA4(>}FE`;?a2yp9_srQv1E$40r%AJZMV)x^bkE zlhP<9%VgBV4*la~H6{r(N=cPQi4jG2zgkTaXq1wLUzrOtT%k9@B!NaLS-4T||GvAu zvxVMYw@CtxQc}gPCt2hH%`v1XG>Q;H2qA