Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Content/Guardian/GuardianHammerAnchor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class GuardianHammerAnchor : OrchidModGuardianAnchor
public int BlockDuration = 0;

public bool Ding = false;

public int HammerAnimFrame = 0;

public bool WeakThrow => Projectile.ai[0] == 1;

Expand Down Expand Up @@ -685,7 +687,7 @@ public override bool OrchidPreDraw(SpriteBatch spriteBatch, ref Color lightColor
if (HammerTexture == null) return false;
Player player = Main.player[Projectile.owner];
OrchidGuardian guardian = player.GetModPlayer<OrchidGuardian>();
Rectangle drawRectangle = HammerTexture.Bounds;
Rectangle drawRectangle = HammerTexture.Frame(1, HammerItem.HammerFrames, 0, HammerAnimFrame % HammerItem.HammerFrames);

if (HammerItem.PreDrawHammer(player, guardian, Projectile, spriteBatch, ref lightColor, ref HammerTexture, ref drawRectangle))
{
Expand Down
9 changes: 6 additions & 3 deletions Content/Guardian/GuardianQuarterstaffAnchor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class GuardianQuarterstaffAnchor : OrchidModGuardianParryAnchor
public Item QuarterstaffItem => Main.player[Projectile.owner].inventory[SelectedItem];
public Texture2D QuarterstaffTexture;
public Texture2D QuarterstaffTextureGlow;
public int QuarterstaffAnimFrame = 0;

public override void SendExtraAI(BinaryWriter writer)
{
Expand Down Expand Up @@ -762,6 +763,8 @@ public override bool OrchidPreDraw(SpriteBatch spriteBatch, ref Color lightColor

if (guardianItem.PreDrawQuarterstaff(spriteBatch, Projectile, player, ref lightColor))
{
Rectangle frame = QuarterstaffTexture.Frame(1, guardianItem.QuarterstaffFrames, 0, QuarterstaffAnimFrame % guardianItem.QuarterstaffFrames);

if (Projectile.ai[0] > 1f || Projectile.ai[0] < 0f || Projectile.ai[2] < 0f)
{ // attacking = draw trail
spriteBatch.End(out SpriteBatchSnapshot spriteBatchSnapshot);
Expand All @@ -770,20 +773,20 @@ public override bool OrchidPreDraw(SpriteBatch spriteBatch, ref Color lightColor
for (int i = 0; i < OldPosition.Count; i++)
{
Vector2 drawPositionTrail = OldPosition[i] - Main.screenPosition + Vector2.UnitY * player.gfxOffY;
spriteBatch.Draw(QuarterstaffTexture, drawPositionTrail, null, lightColor * 0.05f * (i + 1), OldRotation[i] + rotationoffset, QuarterstaffTexture.Size() * 0.5f, Projectile.scale, effect, 0f);
spriteBatch.Draw(QuarterstaffTexture, drawPositionTrail, frame, lightColor * 0.05f * (i + 1), OldRotation[i] + rotationoffset, QuarterstaffTexture.Size() * 0.5f, Projectile.scale, effect, 0f);
}

spriteBatch.End();
spriteBatch.Begin(spriteBatchSnapshot);
}

Vector2 drawPosition = Projectile.Center - Main.screenPosition + Vector2.UnitY * player.gfxOffY;
spriteBatch.Draw(QuarterstaffTexture, drawPosition, null, lightColor, Projectile.rotation + rotationoffset, QuarterstaffTexture.Size() * 0.5f, Projectile.scale, effect, 0f);
spriteBatch.Draw(QuarterstaffTexture, drawPosition, frame, lightColor, Projectile.rotation + rotationoffset, QuarterstaffTexture.Size() * 0.5f, Projectile.scale, effect, 0f);

if (QuarterstaffTextureGlow != null)
{
Color glowColor = guardianItem.GetQuarterstaffGlowmaskColor(player, guardian, Projectile, lightColor);
spriteBatch.Draw(QuarterstaffTextureGlow, drawPosition, null, glowColor, Projectile.rotation + rotationoffset, QuarterstaffTextureGlow.Size() * 0.5f, Projectile.scale, effect, 0f);
spriteBatch.Draw(QuarterstaffTextureGlow, drawPosition, frame, glowColor, Projectile.rotation + rotationoffset, QuarterstaffTextureGlow.Size() * 0.5f, Projectile.scale, effect, 0f);
}
}
guardianItem.PostDrawQuarterstaff(spriteBatch, Projectile, player, lightColor);
Expand Down
21 changes: 13 additions & 8 deletions Content/Guardian/GuardianShieldAnchor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class GuardianShieldAnchor : OrchidModGuardianAnchor
{
public int SelectedItem { get; set; } = -1;
public Item ShieldItem => Main.player[Projectile.owner].inventory[this.SelectedItem];

public int ShieldAnimFrame = 0;

public bool shieldEffectReady = true;
public bool NeedNetUpdate = false;
Expand Down Expand Up @@ -124,9 +126,9 @@ public override void AI()

if (IsLocalOwner)
{
var texture = ModContent.Request<Texture2D>((ShieldItem.ModItem as OrchidModGuardianShield).ShieldTexture).Value;
Projectile.width = (int)(texture.Height * guardian.GuardianWeaponScale);
Projectile.height = (int)(texture.Height * guardian.GuardianWeaponScale);
var texture = ModContent.Request<Texture2D>((ShieldItem.ModItem as OrchidModGuardianShield)?.ShieldTexture).Value;
Projectile.width = (int)(texture.Height * guardian.GuardianWeaponScale / guardianItem.ShieldFrames);
Projectile.height = (int)(texture.Height * guardian.GuardianWeaponScale / guardianItem.ShieldFrames);
}

if (owner.boneGloveItem != null && !owner.boneGloveItem.IsAir && owner.boneGloveTimer == 0)
Expand Down Expand Up @@ -159,9 +161,9 @@ public override void AI()
{
Vector2 oldDimensions = new Vector2(Projectile.width, Projectile.height);
var texture = ModContent.Request<Texture2D>(guardianItem.ShieldTexture).Value;
Projectile.width = (int)(texture.Height * guardian.GuardianWeaponScale);
Projectile.height = (int)(texture.Height * guardian.GuardianWeaponScale);
aimedLocation += (oldDimensions * 0.5f - new Vector2(texture.Height * guardian.GuardianWeaponScale, texture.Height * guardian.GuardianWeaponScale) * 0.5f).Floor();
Projectile.width = (int)(texture.Height * guardian.GuardianWeaponScale / guardianItem.ShieldFrames);
Projectile.height = (int)(texture.Height * guardian.GuardianWeaponScale / guardianItem.ShieldFrames);
aimedLocation += (oldDimensions * 0.5f - new Vector2(texture.Height * guardian.GuardianWeaponScale / guardianItem.ShieldFrames, texture.Height * guardian.GuardianWeaponScale / guardianItem.ShieldFrames) * 0.5f).Floor();
}

aimedLocation += owner.Center.Floor() - oldOwnerPos.Floor();
Expand Down Expand Up @@ -402,12 +404,15 @@ public override bool OrchidPreDraw(SpriteBatch spriteBatch, ref Color lightColor
SpriteEffects effect = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
float colorMult = (Projectile.ai[1] + Projectile.ai[0] > 0 ? 1f : (0.4f + Math.Abs((1f * Main.player[Main.myPlayer].GetModPlayer<OrchidPlayer>().Timer120 - 60) / 120f)));
float flippedRotation = Projectile.rotation + (Projectile.spriteDirection == 1 ? 0 : MathHelper.Pi);
spriteBatch.Draw(texture, drawPosition, null, color * colorMult, flippedRotation, texture.Size() * 0.5f, Projectile.scale, effect, 0f);

Rectangle frame = texture.Frame(1, guardianItem.ShieldFrames, 0, ShieldAnimFrame % guardianItem.ShieldFrames);

spriteBatch.Draw(texture, drawPosition, frame, color * colorMult, flippedRotation, frame.Size() * 0.5f, Projectile.scale, effect, 0f);

if (ModContent.RequestIfExists<Texture2D>(guardianItem.ShieldTexture + "_Glow", out Asset<Texture2D> assetglow))
{
Color glowColor = guardianItem.GetPaviseGlowmaskColor(player, guardian, Projectile, lightColor);
spriteBatch.Draw(assetglow.Value, drawPosition, null, glowColor, flippedRotation, texture.Size() * 0.5f, Projectile.scale, effect, 0f);
spriteBatch.Draw(assetglow.Value, drawPosition, frame, glowColor, flippedRotation, frame.Size() * 0.5f, Projectile.scale, effect, 0f);
}
}
guardianItem.PostDrawShield(spriteBatch, Projectile, player, color);
Expand Down
3 changes: 3 additions & 0 deletions Content/Guardian/OrchidModGuardianHammer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public abstract class OrchidModGuardianHammer : OrchidModGuardianItem
/// <summary>If true, the anchor will load and use ItemName_Hammer.png as its texture.</summary>
public bool hasSpecialHammerTexture = false;
public virtual string HammerTexture => Texture + "_Hammer";
public int HammerFrames = 1;

public virtual void OnBlockContact(Player player, OrchidGuardian guardian, NPC target, Projectile projectile) { } // Called upon pushing an enemy with a throw (can happen repeatedly)
public virtual void OnBlockNPC(Player player, OrchidGuardian guardian, NPC target, Projectile projectile) { } // Called upon blocking an enemy (1 time per throw per enemy)
Expand Down Expand Up @@ -92,6 +93,8 @@ public sealed override void SetDefaults()
BlockDamage = 0.33f;
BlockDuration = 180;
BlockVelocityMult = 1f;

HammerFrames = 1;

OrchidGlobalItemPerEntity orchidItem = Item.GetGlobalItem<OrchidGlobalItemPerEntity>();
orchidItem.guardianWeapon = true;
Expand Down
7 changes: 7 additions & 0 deletions Content/Guardian/OrchidModGuardianQuarterstaff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public virtual void SafeHoldItem(Player player) { }
//public bool SingleSwing = false; // allows a special swing behaviour
/// <summary>Multiplier for the amount of bonus charge gained from hitting with a jab.</summary>
public float JabChargeGain = 1;
/// <summary>
/// The amount of animation frames of the quarterstaff texture.
/// <br/> The animation frame must be set manually using <c>GuardianQuarterstaffAnchor.QuarterstaffAnimFrame</c>.
/// </summary>
public int QuarterstaffFrames = 1;

public sealed override void SetDefaults()
{
Expand All @@ -78,6 +83,8 @@ public sealed override void SetDefaults()
Item.useStyle = ItemUseStyleID.Thrust;
Item.useTime = 30;
Item.knockBack = 5f;

QuarterstaffFrames = 1;

OrchidGlobalItemPerEntity orchidItem = Item.GetGlobalItem<OrchidGlobalItemPerEntity>();
orchidItem.guardianWeapon = true;
Expand Down
3 changes: 3 additions & 0 deletions Content/Guardian/OrchidModGuardianShield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace OrchidMod.Content.Guardian
public abstract class OrchidModGuardianShield : OrchidModGuardianItem
{
public virtual string ShieldTexture => Texture + "_Shield";
public int ShieldFrames = 1;

public virtual void ExtraAIShield(Projectile projectile) { }
public virtual void PostDrawShield(SpriteBatch spriteBatch, Projectile projectile, Player player, Color lightColor) { }
public virtual bool PreDrawShield(SpriteBatch spriteBatch, Projectile projectile, Player player, ref Color lightColor) { return true; }
Expand Down Expand Up @@ -85,6 +87,7 @@ public sealed override void SetDefaults()
discreteAimIncrements = 2;
discreteAimRotation = 0;
lockSlamRotation = false;
ShieldFrames = 1;

OrchidGlobalItemPerEntity orchidItem = Item.GetGlobalItem<OrchidGlobalItemPerEntity>();
orchidItem.guardianWeapon = true;
Expand Down
51 changes: 40 additions & 11 deletions Content/Guardian/Weapons/Shields/Skateboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Microsoft.Xna.Framework.Graphics;
using OrchidMod.Assets;
using System;
using Microsoft.Xna.Framework.Input;
using OrchidMod.Common.ModObjects;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
Expand All @@ -15,6 +17,7 @@ public class Skateboard : OrchidModGuardianShield
public Texture2D TextureWheels;
public float playerVelocity;
public int TimeSpent = 0;
public int AirTime = 0;

public override void SafeSetDefaults()
{
Expand All @@ -30,6 +33,7 @@ public override void SafeSetDefaults()
slamDistance = 50f;
blockDuration = 240;
TextureWheels ??= ModContent.Request<Texture2D>(Texture + "_Wheels", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value;
ShieldFrames = 4;
}

public override void BlockStart(Player player, Projectile shield)
Expand Down Expand Up @@ -60,8 +64,13 @@ public override void PostDrawShield(SpriteBatch spriteBatch, Projectile projecti
var effect = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
for (int i = -1; i < 2; i+= 2)
{
Vector2 drawPosition = projectile.Center - new Vector2(4f, 8f * i).RotatedBy(projectile.rotation) - Main.screenPosition;
spriteBatch.Draw(TextureWheels, drawPosition, null, lightColor * (projectile.ai[0] > 0f ? 1f : 0.5f), projectile.rotation + TimeSpent * 0.05f, TextureWheels.Size() * 0.5f, projectile.scale, effect, 0f);
GuardianShieldAnchor anchor = projectile.ModProjectile as GuardianShieldAnchor;
if (anchor != null && anchor.ShieldAnimFrame % 2 == 0)
{
Vector2 drawPosition = projectile.Center - new Vector2(4f, 8f * i).RotatedBy(projectile.rotation) * (anchor.ShieldAnimFrame == 2 ? -1f : 1f) - Main.screenPosition;
spriteBatch.Draw(TextureWheels, drawPosition, null, lightColor * (projectile.ai[0] > 0f ? 1f : 0.5f), projectile.rotation + TimeSpent * 0.05f, TextureWheels.Size() * 0.5f, projectile.scale, effect, 0f);
}

}
}

Expand All @@ -84,7 +93,7 @@ public override void ExtraAIShield(Projectile projectile)
projectile.rotation = -MathHelper.PiOver2;

// Collision with the ground, do skating stuff
Vector2 collision = Collision.TileCollision(owner.position + new Vector2((owner.width - Item.width) * 0.5f, owner.height), Vector2.UnitY * 12f, Item.width, 14, false, false, (int)owner.gravDir);
Vector2 collision = Collision.TileCollision(owner.position + new Vector2((owner.width - Item.width) * 0.5f, owner.height), Vector2.UnitY * 12f, Item.width, 14, false, owner.controlDown, (int)owner.gravDir);
if (collision != Vector2.UnitY * 12f)
{
owner.fallStart = (int)(owner.position.Y / 16f);
Expand All @@ -93,27 +102,47 @@ public override void ExtraAIShield(Projectile projectile)
owner.velocity.X = playerVelocity;
owner.velocity.Y = 0.1f;

if (playerVelocity < 0)
{
TimeSpent -= 10;
}
else if (playerVelocity > 0)
{
TimeSpent += 9;
}
if (playerVelocity < 0) TimeSpent -= 10;
else if (playerVelocity > 0) TimeSpent += 9;

// owner.eocDash = 0;

AirTime = 0;
anchor.ShieldAnimFrame = 0;


if (Main.rand.NextBool(4)) SoundEngine.PlaySound(SoundID.Item55, projectile.Center);
//
// if (AirTime == 0 && Main.keyState.IsKeyDown(Keys.Space))
// {
// owner.velocity.Y = -8f;
// owner.position.Y -= collision.Y + 1.7f;
// owner.wingTime = 0f;
// owner.eocDash = 0;
// SoundEngine.PlaySound(SoundID.Item32);
// }
}
else
{
AirTime++;
if (AirTime % 4 == 0) anchor.ShieldAnimFrame++;
if (anchor.ShieldAnimFrame > 3) anchor.ShieldAnimFrame = 0;

if (playerVelocity == 0) SoundEngine.PlaySound(SoundID.Item53, projectile.Center);
playerVelocity = owner.velocity.X;
if (playerVelocity < 1f) playerVelocity = 8f * owner.direction;
if (Math.Abs(playerVelocity) < 8f) playerVelocity = 8f * Math.Sign(playerVelocity);
owner.velocity.X = playerVelocity;

projectile.ai[0]++;
}
}
}
else
{
AirTime = 0;
((GuardianShieldAnchor)projectile.ModProjectile).ShieldAnimFrame = 0;
}
}
}
}
Binary file modified Content/Guardian/Weapons/Shields/Skateboard_Shield.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.