From d9a86e187301bffdf35fba73fe3b2df9b2eedff3 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Fri, 19 Feb 2021 17:09:23 -0600 Subject: [PATCH] Start on prism chainsaw --- Items/Weapons/Melee/PrismSaw.cs | 47 ++++++ Items/Weapons/Melee/PrismSaw.png | Bin 0 -> 2096 bytes Projectiles/Melee/PrismSawGlowmask.png | Bin 0 -> 5104 bytes Projectiles/Melee/PrismSawProjectile.cs | 196 +++++++++++++++++++++++ Projectiles/Melee/PrismSawProjectile.png | Bin 0 -> 715 bytes Projectiles/Melee/PrismTooth.cs | 97 +++++++++++ Projectiles/Melee/PrismTooth.png | Bin 0 -> 338 bytes 7 files changed, 340 insertions(+) create mode 100644 Items/Weapons/Melee/PrismSaw.cs create mode 100644 Items/Weapons/Melee/PrismSaw.png create mode 100644 Projectiles/Melee/PrismSawGlowmask.png create mode 100644 Projectiles/Melee/PrismSawProjectile.cs create mode 100644 Projectiles/Melee/PrismSawProjectile.png create mode 100644 Projectiles/Melee/PrismTooth.cs create mode 100644 Projectiles/Melee/PrismTooth.png diff --git a/Items/Weapons/Melee/PrismSaw.cs b/Items/Weapons/Melee/PrismSaw.cs new file mode 100644 index 0000000000..e0454cfca1 --- /dev/null +++ b/Items/Weapons/Melee/PrismSaw.cs @@ -0,0 +1,47 @@ +using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class PrismSaw : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Prism Saw"); + } + + public override void SetDefaults() + { + item.height = 134; + item.width = 54; + item.damage = 3781; + item.melee = true; + item.noMelee = true; + item.noUseGraphic = true; + item.channel = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.useTime = 5; + item.useAnimation = 25; + item.knockBack = 12f; + item.autoReuse = false; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Red; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 1f; + item.Calamity().customRarity = CalamityRarity.Violet; + } + + public override void GetWeaponCrit(Player player, ref int crit) => crit += 18; + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + } +} diff --git a/Items/Weapons/Melee/PrismSaw.png b/Items/Weapons/Melee/PrismSaw.png new file mode 100644 index 0000000000000000000000000000000000000000..7a425f490982e3a43ed8745bb2e84be0a834f24c GIT binary patch literal 2096 zcmV-02+#M4P)Px+>PbXFRCt{2omp%ZRTzN35w!KTmKI8Z(juiUY$9$^G!$Y~;u5#Gl^9}-i2)zP zAc-dGgK>*UA`g|ogE7XqCdLPss3c&Cf<_5qtB_b)C~K)umR@hgaD6!axt`xScjlHW zx4`)l0yA@FYv+9DKmR#1z~Cd@|Ho4R&MNc;cm@|ip)Vi=%MO)QV*-HguHA*XnllV< z2#>{}HN>5bj{@+?dn>Gs<1d&L0Q9Aj0PNne?WA7Z>5eyq$70YMLets48GxVGe*-{u z?SueeSLfD~a&f0S-Vh#(LKq@zFQT$)4E@V#fN|sN0Jwa{O`!*q7^7nN$N=EL{(b+$ zC7(HXLwGC-W(Zd=B2iKr01O#26o88+Uz!Hkw`V)>UsLFq!kgm6@P_bM4A>CTw!297 z_5yJ9=wARF?CFtBp}h!Q(=}IIGs{}8t(yoyefRe&j2&wXcVy$Ptj8;zULC8Pi(Jj&4dJoK*$|agqX9@H&P@Z196c`9 ze$q=2V^oc)4FI}!cUn)r%NV*h;)-E(FGTMr=-A=0CBIn9O^YwFm-}Ogy5~x)_3h91 zh92KlPR9<@o9A208yl8~9xrY=p>%q60B~gEuB_#>LA)V676AjCog`7e)O>A<**Dx~ zExX!yeLRisO)Pz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JH+g5 ze)-R1o_GFBuo8*xYfXy@S{N_s>&Y?PT;?IRnf+>88I(>8sNrTLM&}*v@aj2aD_2)V g`R|_KK66tj*% Main.player[projectile.owner]; + public ref float Time => ref projectile.ai[0]; + public ref float OriginalDamage => ref projectile.ai[1]; + public float ChargeUpPower => MathHelper.Clamp((float)Math.Pow(Time / 240f, 1.6D), 0f, 1f); + public override void SetStaticDefaults() => DisplayName.SetDefault("Verrrrrrrry over the top chainsaw thing"); + + public override void SetDefaults() + { + projectile.width = 132; + projectile.height = 56; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.melee = true; + projectile.ownerHitCheck = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 2; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + Texture2D glowmaskTexture = ModContent.GetTexture("CalamityMod/Projectiles/Melee/PrismSawGlowmask"); + Rectangle glowmaskRectangle = glowmaskTexture.Frame(1, 6, 0, projectile.frame); + Vector2 origin = texture.Size() * 0.5f; + Vector2 drawPosition = projectile.Center - Main.screenPosition; + SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + spriteBatch.Draw(texture, drawPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, direction, 0f); + spriteBatch.Draw(glowmaskTexture, drawPosition, glowmaskRectangle, Color.White, projectile.rotation, origin, projectile.scale, direction, 0f); + return false; + } + + public override void AI() + { + PlayChainsawSounds(); + DetermineDamage(); + + Vector2 playerRotatedPoint = Owner.RotatedRelativePoint(Owner.MountedCenter); + if (Main.myPlayer == projectile.owner) + { + if (Owner.channel && !Owner.noItems && !Owner.CCed) + HandleChannelMovement(playerRotatedPoint); + else + projectile.Kill(); + } + + DetermineVisuals(playerRotatedPoint); + ManipulatePlayerValues(); + EmitPrettyDust(); + + if (Time > 90f && Time % 36f == 35f) + ReleasePrismTeeth(); + + // Prevent the projectile from dying normally. However, if anything for whatever reason + // goes wrong it will immediately be destroyed on the next frame. + projectile.timeLeft = 2; + + Time++; + } + + public void PlayChainsawSounds() + { + if (projectile.soundDelay <= 0) + { + Main.PlaySound(SoundID.Item22, projectile.position); + projectile.soundDelay = (int)MathHelper.Lerp(30f, 12f, ChargeUpPower); + } + } + + public void DetermineDamage() + { + // Set the initial damage the moment it's created. + if (Main.myPlayer == projectile.owner && OriginalDamage == 0f) + { + OriginalDamage = projectile.damage; + projectile.netUpdate = true; + } + + // And then do time based calculations. This does not execute if the original damage is 0. + if (OriginalDamage != 0f) + projectile.damage = (int)MathHelper.SmoothStep(OriginalDamage * 0.36f, OriginalDamage, ChargeUpPower); + } + + public void DetermineVisuals(Vector2 playerRotatedPoint) + { + float velocityAngle = projectile.velocity.ToRotation(); + projectile.rotation = velocityAngle; + + int oldDirection = projectile.spriteDirection; + if (oldDirection == -1) + projectile.rotation += MathHelper.Pi; + + projectile.direction = projectile.spriteDirection = (Math.Cos(velocityAngle) > 0).ToDirectionInt(); + + if (projectile.spriteDirection != oldDirection) + projectile.rotation -= MathHelper.Pi; + + // Positioning close to the end of the player's arm. + projectile.position = playerRotatedPoint - projectile.Size * 0.5f + velocityAngle.ToRotationVector2() * 30f; + + // Update the position a tiny bit every frame at random to make it look like the saw is vibrating. + projectile.position += Main.rand.NextVector2Circular(1.4f, 1.4f); + + // Update glowmask frames. + projectile.frameCounter += (int)MathHelper.SmoothStep(12f, 33f, ChargeUpPower); + if (projectile.frameCounter >= 32) + { + projectile.frame = (projectile.frame + 1) % 6; + projectile.frameCounter = 0; + } + } + + public void HandleChannelMovement(Vector2 playerRotatedPoint) + { + float speed = 1f; + if (Owner.ActiveItem().shoot == projectile.type) + speed = Owner.ActiveItem().shootSpeed * projectile.scale; + + Vector2 currentAimDirection = projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction); + Vector2 idealAimDirection = (Main.MouseWorld - playerRotatedPoint).SafeNormalize(Vector2.UnitX * Owner.direction); + + float angularAimVelocity = 0.16f; + float directionAngularDisparity = projectile.velocity.AngleBetween(idealAimDirection) / MathHelper.Pi; + + // Increase the turn speed if close to the ideal direction, since successive linear interpolations + // are asymptotic. + angularAimVelocity += MathHelper.Lerp(0f, 0.25f, Utils.InverseLerp(0.28f, 0.08f, directionAngularDisparity, true)); + + if (directionAngularDisparity < 0.02f) + projectile.velocity = Vector2.Lerp(currentAimDirection, idealAimDirection, angularAimVelocity); + else + projectile.velocity = idealAimDirection; + + projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * speed; + } + + public void ManipulatePlayerValues() + { + Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); + Owner.heldProj = projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.ChangeDir(projectile.direction); + } + + public void EmitPrettyDust() + { + if (Main.dedServ) + return; + + for (int i = 0; i < 2; i++) + { + Vector2 spawnPosition = projectile.Center + projectile.velocity * 35f; + spawnPosition += Main.rand.NextVector2CircularEdge(9f, 35f).RotatedBy(projectile.velocity.ToRotation() + MathHelper.PiOver2); + + Dust rainbowSpark = Dust.NewDustPerfect(spawnPosition, 261); + rainbowSpark.velocity = projectile.velocity * 3f + Main.rand.NextVector2CircularEdge(1.5f, 1.5f); + rainbowSpark.noGravity = true; + rainbowSpark.color = Main.hslToRgb((Time / 40f + Main.rand.NextFloat(-0.1f, 0.1f)) % 1f, 0.95f, 0.6f); + rainbowSpark.scale = Main.rand.NextFloat(0.9f, 1.25f); + } + } + + public void ReleasePrismTeeth() + { + if (Main.myPlayer != projectile.owner) + return; + + float shootReach = MathHelper.SmoothStep(projectile.width * 1.2f, projectile.width * 2.25f + 20f, ChargeUpPower); + Projectile.NewProjectile(Owner.Center, projectile.velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner, 0f, shootReach); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // Collision is done as a line to bypass the fact that hitboxes cannot rotate and that + // this projectile is notably flat in terms of sprite shape. + float _ = 0f; + float width = projectile.scale * 36f; + Vector2 start = projectile.Center; + Vector2 end = projectile.Center + projectile.velocity * 70f; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, width, ref _); + } + } +} diff --git a/Projectiles/Melee/PrismSawProjectile.png b/Projectiles/Melee/PrismSawProjectile.png new file mode 100644 index 0000000000000000000000000000000000000000..f0e5ea6ab42fab4e1319ef2b370ac0db595fcd12 GIT binary patch literal 715 zcmV;+0yO=JP)Px#1ZP1_K>z@;j|==^1poj5Cs0gOMF0Q*P+4a)I6odBA#;3-$38xXD^{AMuCTqu z99dUBmFYfNt^fc4@9Rvz0000DbW%=J|NsC0|NsC0|NsC006pj;h5!Hn32;bRa{vGi z!TfwarE_WhrC9G@*nr%Gv+Xhu6}2|vcZ z29l-w4$`iu_nArJT#cC|az0aJE(s{*9Fh1EeG5`r7KxmpF@r=ukfliDj4hc%LS>;; za=u)S*N7>x7%DWroE*+eh5oS`5ha#|hb|;S@#fKvs06)tlu8VVEtE!}KXx5R9Z7o9 z5cGv*dlO6I{FwwLJS7U;8AYONpv4?A;Gc2dnAfoCMjZ$sp&g-&Na=cAmNqpUNSkab zPS>!>2gY&F1^St-x)DX9-6{m6^zq>muF*Hk6G&!V_3=^}Vzy{4^dG?(kVQ2hk^}`= zsH=~tY|ff-G`BWf!=|1>6vc_9#p~XRG~!7pnRfJxX|tPJ!g2&a$BxaA#ulQV(_?g3amvS*K!a&MK)pCuE#P4i0pAsE z7ueuaO1a%o@MtMSmY@(41o03F)j}=e?hh9UDbm}EUUr~oMMFxshD6%B3Z-}s}6IPyMZ=){%i*cw9`UF0Zc xkl1RNL*+k8Y&9I4I*3^$wi-5cC;=qy_aF4Xz^SGdP>TQn002ovPDHLkV1kA8E=>Rc literal 0 HcmV?d00001 diff --git a/Projectiles/Melee/PrismTooth.cs b/Projectiles/Melee/PrismTooth.cs new file mode 100644 index 0000000000..60f7eb5841 --- /dev/null +++ b/Projectiles/Melee/PrismTooth.cs @@ -0,0 +1,97 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class PrismTooth : ModProjectile + { + internal PrimitiveTrail TrailDrawer; + public const int Lifetime = 30; + public Player Owner => Main.player[projectile.owner]; + public ref float Time => ref projectile.ai[0]; + public ref float ShootReach => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Prism Tooth"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 36; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 35; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.timeLeft = Lifetime; + projectile.melee = true; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.Write((byte)projectile.direction); + + public override void ReceiveExtraAI(BinaryReader reader) => projectile.direction = reader.ReadByte(); + + public override void AI() + { + // Determine the initial direction of the tooth in terms of its orbit. + if (Main.myPlayer == projectile.owner && projectile.spriteDirection == 0) + { + projectile.spriteDirection = Main.rand.NextBool(2).ToDirectionInt(); + projectile.netUpdate = true; + } + + projectile.rotation = MathHelper.Pi * Time / Lifetime; + if (projectile.spriteDirection == -1) + projectile.rotation = MathHelper.Pi - projectile.rotation; + projectile.rotation += projectile.velocity.ToRotation(); + + // In this context, the velocity is simply the initial direction as a unit vector- it does not + // actually influence movement in any way. + float angle = MathHelper.TwoPi * Time / Lifetime - MathHelper.PiOver2; + if (projectile.spriteDirection == -1) + angle += MathHelper.Pi; + + Vector2 baseDirection = angle.ToRotationVector2(); + baseDirection.X *= 0.25f; + baseDirection.Y = baseDirection.Y * 0.5f + 0.5f; + baseDirection = baseDirection.RotatedBy(projectile.velocity.ToRotation() - MathHelper.PiOver2); + + projectile.Center = Owner.RotatedRelativePoint(Owner.MountedCenter) + baseDirection * ShootReach; + projectile.Opacity = Utils.InverseLerp(0f, 12f, Time, true) * Utils.InverseLerp(Lifetime, Lifetime - 12f, Time, true); + + Time++; + } + + public override Color? GetAlpha(Color lightColor) + { + float hue = (projectile.identity % 9f / 9f + projectile.timeLeft / (float)Lifetime) % 1f; + return Color.Lerp(lightColor, Main.hslToRgb(hue, 0.95f, 0.55f), 0.35f) * projectile.Opacity; + } + + internal float WidthFunction(float completionRatio) => 54f; + + internal Color ColorFunction(float completionRatio) + { + Color color = Color.Lerp(Color.White, Color.Violet, Utils.InverseLerp(0f, 0.7f, completionRatio, true)) * (1f - Utils.InverseLerp(0f, 0.98f, completionRatio, true)); + color.A /= 2; + return color; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, false, GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"]); + + GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); + TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition + projectile.velocity.SafeNormalize(Vector2.Zero) * 86f, 60); + return true; + } + + public override bool ShouldUpdatePosition() => false; + } +} diff --git a/Projectiles/Melee/PrismTooth.png b/Projectiles/Melee/PrismTooth.png new file mode 100644 index 0000000000000000000000000000000000000000..3201a55ae98713958e02f1bdc52eb32a629fbf7a GIT binary patch literal 338 zcmeAS@N?(olHy`uVBq!ia0vp^azJdt!3-o<-K;nOq!^2X+?^QKos)S9O9%LbxB}__|NkHQ|26Z&on;>~|NlS!|7ZUHt@$S)YE z1`HU2{VRk(f(0It#S9F5he4R}c>anMpx|mx7sn6_|GAeg3N+Rm}2RF`{%g0~0YFlo_x<@}U4}7XR@HtE1VWq(1-wjV=v+E>XD&#igG*5Z6cjmDV zKi{usp4b2QjFLtDd5HoWwzDQ1Jm&DOk$C)ak#BhQlf|WJbBb&Xo;S)!?@Kn{AJ%i% zq~O{j9VVy1V^`U_rzGVx|L%MY( W_{r~NI2{afHiM_DpUXO@geCxTo{zQw literal 0 HcmV?d00001