Urchin Spear
This commit is contained in:
1 parent
064c8239bd
commit
42ddaa52e9
7 files changed
+113
-19
No files matched your search
@@ -8,12 +8,12 @@ namespace CalamityMod.Items.Armor
|
||||
{
|
||||
[AutoloadEquip(EquipType.Head)]
|
||||
[LegacyName("VictideHelm")]
|
||||
public class VictideSeaShellmet : ModItem
|
||||
public class VictideShellmet : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
SacrificeTotal = 1;
|
||||
DisplayName.SetDefault("Victide Sea Shellmet");
|
||||
DisplayName.SetDefault("Victide Shellmet");
|
||||
Tooltip.SetDefault("5% increased melee damage");
|
||||
}
|
||||
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 673 B After Width: | Height: | Size: 673 B |
File renamed without changes.
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 56;
|
||||
Item.damage = 28;
|
||||
Item.damage = 33;
|
||||
Item.DamageType = DamageClass.Melee;
|
||||
Item.noMelee = true;
|
||||
Item.useTurn = true;
|
||||
@@ -37,6 +37,11 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
Item.shootSpeed = 4f;
|
||||
}
|
||||
|
||||
public override void HoldItem(Player player)
|
||||
{
|
||||
player.Calamity().mouseWorldListener = true;
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
|
||||
|
||||
public override void AddRecipes()
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
|
||||
}
|
||||
|
||||
//Swing animation keys
|
||||
//Squish animation keys
|
||||
public CurveSegment anticipation = new CurveSegment(EasingType.PolyInOut, 0f, 1f, 0.35f, 3);
|
||||
public CurveSegment contraction = new CurveSegment(EasingType.PolyOut, 0.5f, 1.35f, -0.85f, 5);
|
||||
public CurveSegment retract = new CurveSegment(EasingType.SineInOut, 0.7f, 0.5f, 0.5f);
|
||||
|
||||
@@ -1,12 +1,63 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using Terraria.Audio;
|
||||
using System;
|
||||
using CalamityMod.Particles;
|
||||
using static CalamityMod.CalamityUtils;
|
||||
|
||||
namespace CalamityMod.Projectiles.Melee.Spears
|
||||
{
|
||||
public class RedtideSpearProjectile : BaseSpearProjectile
|
||||
public class RedtideSpearProjectile : ModProjectile
|
||||
{
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
public static int Lifetime => 28;
|
||||
public int Timer => Lifetime - Projectile.timeLeft;
|
||||
|
||||
#region Thrust
|
||||
//Basic animation variables.
|
||||
public float ThrustProgress => Timer / (float)Lifetime;
|
||||
public float ThrustRotation => Projectile.velocity.ToRotation() + Owner.direction * RotationShift;
|
||||
public float BaseRotation => Projectile.velocity.ToRotation();
|
||||
|
||||
//Thrust animation keys
|
||||
public CurveSegment thrust = new CurveSegment(EasingType.PolyIn, 0f, 0.15f, 0.85f, 3);
|
||||
public CurveSegment hold = new CurveSegment(EasingType.SineBump, 0.3f, 1f, 0.2f);
|
||||
public CurveSegment retract = new CurveSegment(EasingType.PolyOut, 0.7f, 1f, -1f, 2);
|
||||
public CurveSegment correct = new CurveSegment(EasingType.PolyIn, 0.85f, 0f, 0.17f);
|
||||
internal float Displacement => PiecewiseAnimation(ThrustProgress, new CurveSegment[] { thrust, hold, retract, correct });
|
||||
|
||||
internal const float startRotation = MathHelper.PiOver4 * 0.1f;
|
||||
internal const float downwardsRotation = MathHelper.PiOver4 * 0.15f;
|
||||
internal const float upwardsRotation = MathHelper.PiOver4 * -0.44f;
|
||||
internal const float loweredTime = 0.25f;
|
||||
|
||||
public CurveSegment downwards = new CurveSegment(EasingType.SineOut, 0f, startRotation, downwardsRotation, 2);
|
||||
public CurveSegment upstamp = new CurveSegment(EasingType.SineIn, loweredTime, startRotation + downwardsRotation, upwardsRotation);
|
||||
public CurveSegment stayUp = new CurveSegment(EasingType.Linear, 0.8f, startRotation + downwardsRotation + upwardsRotation, 0f);
|
||||
internal float RotationShift => PiecewiseAnimation(ThrustProgress, new CurveSegment[] { downwards, upstamp, stayUp });
|
||||
public int InitializationTime => (int)(loweredTime * Lifetime);
|
||||
#endregion
|
||||
|
||||
#region Drag along the ground
|
||||
|
||||
//Player can only do the run attack while moving fast horizontally, but remaining on the ground
|
||||
public static int MaxRunTime = 300;
|
||||
public bool CanRunAttack => Owner.velocity.Y == 0 && Math.Abs(Owner.velocity.X) >= Owner.maxRunSpeed * 0.7f && Owner.channel && !RunBroken;
|
||||
public ref float RunTimer => ref Projectile.ai[0];
|
||||
public bool RunBroken
|
||||
{
|
||||
get => Projectile.ai[1] > 0f; //Basically tracks if the run has been broken.
|
||||
set { Projectile.ai[1] = value ? 1f : 0f; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal static enum AttackState { ForwardThrust, RunAttack, UpwardsThrust };
|
||||
public AttackState CurrentMode => (RunBroken && RunTimer <= InitializationTime) ? AttackState.ForwardThrust : (RunBroken || RunTimer > MaxRunTime) ? AttackState.UpwardsThrust : AttackState.RunAttack;
|
||||
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Redtide Spear");
|
||||
@@ -14,11 +65,10 @@ namespace CalamityMod.Projectiles.Melee.Spears
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 56; //The width of the .png file in pixels divided by 2.
|
||||
Projectile.aiStyle = 19;
|
||||
Projectile.width = 56;
|
||||
Projectile.DamageType = DamageClass.Melee; //Dictates whether this is a melee-class weapon.
|
||||
Projectile.timeLeft = 90;
|
||||
Projectile.height = 56; //The height of the .png file in pixels divided by 2.
|
||||
Projectile.timeLeft = Lifetime;
|
||||
Projectile.height = 56;
|
||||
Projectile.friendly = true;
|
||||
Projectile.hostile = false;
|
||||
Projectile.tileCollide = false;
|
||||
@@ -27,18 +77,47 @@ namespace CalamityMod.Projectiles.Melee.Spears
|
||||
Projectile.ownerHitCheck = true;
|
||||
}
|
||||
|
||||
public override float InitialSpeed => 3f;
|
||||
public override float ReelbackSpeed => 2.4f;
|
||||
public override float ForwardSpeed => 0.95f;
|
||||
public override Action<Projectile> EffectBeforeReelback => (proj) =>
|
||||
public override bool ShouldUpdatePosition()
|
||||
{
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X + Projectile.velocity.X, Projectile.Center.Y + Projectile.velocity.Y,
|
||||
Projectile.velocity.X * 1.6f, Projectile.velocity.Y * 1.6f, ModContent.ProjectileType<UrchinSpikeFugu>(), Projectile.damage, Projectile.knockBack * 0.5f, Projectile.owner, 0f, 0f);
|
||||
};
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
|
||||
{
|
||||
float collisionPoint = 0f;
|
||||
float bladeLenght = 85 * Projectile.scale;
|
||||
float bladeWidth = 20 * Projectile.scale;
|
||||
return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center + ThrustRotation.ToRotationVector2() * bladeLenght * -0.5f, Projectile.Center + ThrustRotation.ToRotationVector2() * bladeLenght * 0.5f, bladeWidth, ref collisionPoint);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
UpdateOwnerVars();
|
||||
Vector2 thrust = ThrustRotation.ToRotationVector2() * (Displacement * 40f + 5f);
|
||||
Projectile.Center = Owner.Center + thrust;
|
||||
|
||||
}
|
||||
|
||||
public void UpdateOwnerVars()
|
||||
{
|
||||
Owner.direction = Math.Sign(BaseRotation.ToRotationVector2().X);
|
||||
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, ThrustRotation - MathHelper.PiOver2);
|
||||
Owner.heldProj = Projectile.whoAmI;
|
||||
Owner.itemTime = 2;
|
||||
Owner.itemAnimation = 2;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
target.AddBuff(BuffID.Poisoned, 180);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
|
||||
|
||||
Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor, ThrustRotation + MathHelper.PiOver2 * 1.5f - MathHelper.ToRadians(12), texture.Size() / 2f, Projectile.scale, 0, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
float armPointingDirection = ((Owner.Calamity().mouseWorld - Owner.Center).ToRotation());
|
||||
|
||||
//"crop" the rotation so the player only tilts the fishing rod slightly up and slightly down.
|
||||
//"crop" the rotation so the player only points their arm in a smaller range. (The back arm points in the throw direction)
|
||||
if (armPointingDirection < MathHelper.PiOver2 && armPointingDirection >= -MathHelper.PiOver2)
|
||||
armPointingDirection = -MathHelper.PiOver2 + MathHelper.PiOver4 / 2f + MathHelper.PiOver2 * 1.5f * Utils.GetLerpValue(0f, MathHelper.Pi, armPointingDirection + MathHelper.PiOver2, true);
|
||||
else
|
||||
@@ -126,6 +126,16 @@ namespace CalamityMod.Projectiles.Melee
|
||||
}
|
||||
}
|
||||
|
||||
//If we don't do that, the hit enemies get knocked back towards you if you hit them from the right??
|
||||
public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
|
||||
{
|
||||
// This would knock enemies away consistently, but i'm choosing to go with the other option
|
||||
//hitDirection = Math.Sign(target.Center.X - Owner.Center.X);
|
||||
|
||||
//Doing it this way lets the player choose if they want to knockback enemies towards them by pointing away from them
|
||||
hitDirection = Owner.direction;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Owner.direction = Math.Sign(Owner.Calamity().mouseWorld.X - Owner.position.X);
|
||||
|
||||
Reference in new issue
Block a user