Death's Ascension LClick visual edits

only the energy part of the swing now draws at full brightness

the player's arm now moves along with the scythe instead of pointing in one direction the entire time
This commit is contained in:
GinYuH committed 2024-08-13 23:30:46 -07:00
1 parent e97ecbbecd
commit 5feca4bde9
2 files changed
+45 -9

No files matched your search

+45 -9
View File
@@ -1,6 +1,7 @@
using CalamityMod.Items.Weapons.Melee;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
@@ -26,6 +27,16 @@ namespace CalamityMod.Projectiles.Melee
}
public Player Owner => Main.player[Projectile.owner];
public static Asset<Texture2D> glowTexture = null;
public override void SetStaticDefaults()
{
if (!Main.dedServ)
{
glowTexture = ModContent.Request<Texture2D>(Texture + "Glow", AssetRequestMode.AsyncLoad);
}
}
public override void SetDefaults()
{
Projectile.width = 159;
@@ -45,16 +56,17 @@ namespace CalamityMod.Projectiles.Melee
{
//Frames and crap
Projectile.frameCounter++;
if (Projectile.frameCounter % 3 == 0)
if (Projectile.frameCounter > 2)
{
CurrentFrame++;
if (frameX >= 2)
CurrentFrame = 0;
}
if (frameX == 0 && frameY == 3 && Projectile.frameCounter % 3 == 0)
{
SoundEngine.PlaySound(SoundID.Item71, Projectile.position);
if (frameX == 0 && frameY == 3)
{
SoundEngine.PlaySound(SoundID.Item71, Projectile.position);
}
Projectile.frameCounter = 0;
}
if ((frameX == 0 && frameY >= 3) || (frameX == 1 && frameY <= 1))
@@ -91,6 +103,10 @@ namespace CalamityMod.Projectiles.Melee
// Prevents the projectile from dying
Projectile.timeLeft = 2;
// Move the player's arm accordingly
bool ownerFacingRight = Owner.direction == 1;
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, GetArmRotation() * (ownerFacingRight ? 1 : -1) - MathHelper.PiOver2 + (ownerFacingRight ? 0 : MathHelper.Pi));
// Player item-based field manipulation.
Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation();
Owner.heldProj = Projectile.whoAmI;
@@ -98,6 +114,27 @@ namespace CalamityMod.Projectiles.Melee
Owner.itemAnimation = 2;
}
// This hurt my soul to do, but because the swing is done with a sprite animation, tracking specific visual rotation of the weapon is nigh impossible
public float GetArmRotation()
{
return (frameX, frameY) switch
{
(0, 0) => -2.12f,
(0, 1) => -2.59f,
(0, 2) => -2.29f,
(0, 3) => -0.97f,
(0, 4) => 0.75f,
(0, 5) => 1.07f,
(1, 0) => 1.4f,
(1, 1) => 1.14f,
(1, 2) => 0.85f,
(1, 3) => 0.4f,
(1, 4) => -0.28f,
(1, 5) => -1.8f,
_ => 0
};
}
public void HandleChannelMovement(Vector2 playerRotatedPoint)
{
Vector2 newVelocity = Vector2.UnitX * (Main.MouseWorld.X > playerRotatedPoint.X).ToDirectionInt();
@@ -111,14 +148,13 @@ namespace CalamityMod.Projectiles.Melee
public override bool PreDraw(ref Color lightColor)
{
if (Projectile.frameCounter <= 1)
return false;
Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value;
Vector2 position = Projectile.Center - Main.screenPosition + (Projectile.spriteDirection == -1 ? new Vector2(60, 0) : new Vector2(-60, 0));
Vector2 position = Projectile.Center - Main.screenPosition + (Projectile.spriteDirection == -1 ? new Vector2(60, 0) : new Vector2(-60, 0)) - Projectile.velocity;
Vector2 origin = texture.Size() / new Vector2(2f, 6f) * 0.5f;
Rectangle frame = texture.Frame(2, 6, frameX, frameY);
SpriteEffects spriteEffects = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
Main.EntitySpriteDraw(texture, position, frame, Color.White, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0);
Main.EntitySpriteDraw(texture, position, frame, lightColor, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0);
Main.EntitySpriteDraw(glowTexture.Value, position, frame, Color.White, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0);
return false;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB