Bladecrest Oathsword Start
No tooltip and there's a bit of polish needed but the function is basically done
This commit is contained in:
1 parent
f2bc3bd6bf
commit
429548b093
13 files changed
+365
-261
No files matched your search
@@ -10,47 +10,34 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
public class BladecrestOathsword : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Weapons.Melee";
|
||||
public int throwCount = 0;
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 56;
|
||||
Item.height = 56;
|
||||
Item.damage = 17;
|
||||
Item.DamageType = DamageClass.Melee;
|
||||
Item.useAnimation = 21;
|
||||
Item.useTime = 21;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.knockBack = 4f;
|
||||
Item.UseSound = SoundID.Item1;
|
||||
Item.autoReuse = true;
|
||||
|
||||
Item.damage = 28;
|
||||
Item.knockBack = 2f;
|
||||
Item.useTime = 53;
|
||||
Item.useAnimation = 53;
|
||||
Item.shoot = ModContent.ProjectileType<BladecrestOathswordThrownBlade>();
|
||||
Item.shootSpeed = 6f;
|
||||
|
||||
Item.noMelee = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.useTurn = false;
|
||||
Item.channel = true;
|
||||
Item.DamageType = DamageClass.Melee;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.UseSound = null;
|
||||
Item.autoReuse = true;
|
||||
|
||||
Item.value = CalamityGlobalItem.RarityOrangeBuyPrice;
|
||||
Item.rare = ItemRarityID.Orange;
|
||||
Item.shootSpeed = 6f;
|
||||
// Set so the item isn't classified as true melee
|
||||
Item.shoot = ModContent.ProjectileType<BladecrestOathswordProj>();
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player)
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
||||
{
|
||||
int bladeProjID = ModContent.ProjectileType<BladecrestOathswordProj>();
|
||||
foreach (Projectile p in Main.ActiveProjectiles)
|
||||
{
|
||||
if (p.type != bladeProjID || p.owner != player.whoAmI)
|
||||
continue;
|
||||
|
||||
return p.ModProjectile<BladecrestOathswordProj>().PostSwingRepositionDelay <= 0f;
|
||||
}
|
||||
|
||||
return base.CanUseItem(player);
|
||||
throwCount++;
|
||||
Projectile.NewProjectile(source, player.MountedCenter, velocity, type, damage, knockback, player.whoAmI, 0, throwCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return false because Shoot code is not actually relevant
|
||||
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo spawnSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback) => false;
|
||||
|
||||
public override bool? CanHitNPC(Player player, NPC target) => false;
|
||||
|
||||
public override bool CanHitPvp(Player player, Player target) => false;
|
||||
}
|
||||
}
|
||||
@@ -311,3 +311,4 @@ WulfrumScrew.DisplayName: Wulfrum Screw
|
||||
WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver
|
||||
YinYoDark.DisplayName: Dark Shard
|
||||
YinYoLight.DisplayName: Light Shard
|
||||
BladecrestOathswordThrownBlade.DisplayName: Bladecrest Oathsword Thrown Blade
|
||||
@@ -337,6 +337,7 @@ namespace CalamityMod.NPCs
|
||||
/// </summary>
|
||||
public int cursorFocus = 0;
|
||||
public const int cursorFocusMax = 300;
|
||||
public int demonSwordImpales = 0;
|
||||
|
||||
/// <summary>
|
||||
/// If set to true, prevents this NPC from dealing contact damage.<br/>
|
||||
@@ -593,6 +594,7 @@ namespace CalamityMod.NPCs
|
||||
myClone.veriumDoomStacks = veriumDoomStacks;
|
||||
myClone.veriumDoomMarked = veriumDoomMarked;
|
||||
myClone.cursorFocus = cursorFocus;
|
||||
myClone.demonSwordImpales = demonSwordImpales;
|
||||
|
||||
myClone.pacified = pacified;
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -1,229 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
public class BladecrestOathswordProj : BaseIdleHoldoutProjectile
|
||||
{
|
||||
public override LocalizedText DisplayName => CalamityUtils.GetItemName<BladecrestOathsword>();
|
||||
public enum SwingState : byte
|
||||
{
|
||||
Default,
|
||||
Swinging
|
||||
}
|
||||
|
||||
public int Direction = 1;
|
||||
public SwingState CurrentState;
|
||||
public ref float SwingDirection => ref Projectile.ai[0];
|
||||
public ref float BladeHorizontalFactor => ref Projectile.ai[1];
|
||||
public ref float PostSwingRepositionDelay => ref Projectile.localAI[0];
|
||||
public ref float ChargePower => ref Projectile.localAI[1];
|
||||
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Melee/BladecrestOathsword";
|
||||
public override int AssociatedItemID => ModContent.ItemType<BladecrestOathsword>();
|
||||
public override int IntendedProjectileType => ModContent.ProjectileType<BladecrestOathswordProj>();
|
||||
public override bool? CanDamage() => CurrentState != 0; //Could also disable the damage during the channel state,
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
base.SetStaticDefaults(); // DO NOT REMOVE THIS
|
||||
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 3;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = Projectile.height = 56;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Melee;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft = 90000;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = 12;
|
||||
Projectile.noEnchantmentVisuals = true;
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Direction);
|
||||
writer.Write(PostSwingRepositionDelay);
|
||||
writer.Write((byte)CurrentState);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
Direction = reader.ReadInt32();
|
||||
PostSwingRepositionDelay = reader.ReadSingle();
|
||||
CurrentState = (SwingState)reader.ReadByte();
|
||||
}
|
||||
|
||||
public override void SafeAI()
|
||||
{
|
||||
// Initialize the animation max time if necessary.
|
||||
if (Owner.itemAnimationMax == 0)
|
||||
Owner.itemAnimationMax = (int)(Owner.ActiveItem().useAnimation * Owner.GetAttackSpeed<MeleeDamageClass>());
|
||||
|
||||
// Decide the current phase state of the blade.
|
||||
DecideCurrentState();
|
||||
|
||||
Direction = Owner.direction;
|
||||
|
||||
//Set the owner's arm to rotate with the blade
|
||||
if (Owner.itemAnimation > 0)
|
||||
{
|
||||
float armPointingDirection = Projectile.rotation + MathHelper.ToRadians(240);
|
||||
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armPointingDirection);
|
||||
}
|
||||
|
||||
// Glue the sword to its owner.
|
||||
Projectile.Opacity = 1f;
|
||||
Projectile.position = Owner.RotatedRelativePoint(Owner.MountedCenter, true) - Projectile.Size * 0.5f + Vector2.UnitY * Owner.gfxOffY;
|
||||
|
||||
float swingSpeedInterpolant = 0.27f;
|
||||
float swingCompletion = 1f - Owner.itemAnimation / (float)Owner.itemAnimationMax;
|
||||
float unchangedSwingCompletion = swingCompletion;
|
||||
if (SwingDirection == -1f)
|
||||
swingCompletion = 1f - swingCompletion;
|
||||
|
||||
// Calculate the direction of the blade.
|
||||
Vector3 aimDirection3D = Vector3.Transform(Vector3.UnitX, Matrix.CreateRotationZ(MathHelper.PiOver2 * -Direction));
|
||||
|
||||
if ((swingCompletion > 0f && swingCompletion < 1f) || PostSwingRepositionDelay > 0f)
|
||||
{
|
||||
swingSpeedInterpolant = MathHelper.Lerp(swingSpeedInterpolant, 1f, Utils.GetLerpValue(0f, 0.2f, swingCompletion, true));
|
||||
|
||||
float horizontalAngle = MathHelper.Lerp(-1.2f, 2.6f, (float)Math.Pow(MathHelper.SmoothStep(0f, 1f, swingCompletion), 3D)) * Direction;
|
||||
Matrix offsetLinearTransformation = Matrix.CreateRotationZ(horizontalAngle);
|
||||
|
||||
aimDirection3D = Vector3.Transform(Vector3.UnitX, offsetLinearTransformation);
|
||||
}
|
||||
|
||||
// Disable the holdout effect. This was decided after indeciciveness with what would be best.
|
||||
else
|
||||
Projectile.Opacity = 0f;
|
||||
|
||||
// Determine the horizontal stretch offset of the blade. This is used in matrix math below to create 2.5D visuals.
|
||||
BladeHorizontalFactor = MathHelper.Lerp(1f, 1.25f, (aimDirection3D.X * 0.5f + 0.5f) * Utils.GetLerpValue(1f, 0.8f, unchangedSwingCompletion, true));
|
||||
|
||||
float baseRotation = new Vector2(aimDirection3D.X, aimDirection3D.Y).ToRotation();
|
||||
|
||||
// Hold the blade upwards if not firing.
|
||||
if (CurrentState == SwingState.Swinging)
|
||||
PostSwingRepositionDelay = 10f;
|
||||
else if (PostSwingRepositionDelay > 0f)
|
||||
PostSwingRepositionDelay--;
|
||||
|
||||
float idealRotation = baseRotation;
|
||||
|
||||
Owner.itemRotation = 0f;
|
||||
Owner.heldProj = Projectile.whoAmI;
|
||||
|
||||
idealRotation += MathHelper.PiOver4;
|
||||
if (Direction == -1)
|
||||
idealRotation += MathHelper.Pi;
|
||||
|
||||
// Define rotation.
|
||||
Projectile.rotation = Projectile.rotation.AngleTowards(idealRotation, swingSpeedInterpolant * 0.45f).AngleLerp(idealRotation, swingSpeedInterpolant * 0.2f);
|
||||
|
||||
// Offset the blade so that the handle is attached to the owner's hand.
|
||||
Vector2 bladeOffset = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * Projectile.width * 0.65f;
|
||||
bladeOffset += Vector2.UnitY * Owner.gfxOffY;
|
||||
Projectile.position += bladeOffset;
|
||||
|
||||
// Create demon magic dust along the blade when swinging, as well as demon blood scythes.
|
||||
if (PostSwingRepositionDelay >= 10f && CurrentState == SwingState.Swinging)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Dust shadowflame = Dust.NewDustPerfect(Projectile.Center + (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * Projectile.width * Main.rand.NextFloat(0.4f), 27);
|
||||
shadowflame.velocity = (Projectile.oldRot[0] - Projectile.oldRot[1]).ToRotationVector2() * Main.rand.NextFloat(4f, 10f);
|
||||
shadowflame.velocity += (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * 7.5f;
|
||||
shadowflame.scale = Main.rand.NextFloat(1f, 1.5f);
|
||||
shadowflame.fadeIn = 0.5f;
|
||||
shadowflame.noGravity = true;
|
||||
}
|
||||
|
||||
if (Main.myPlayer == Projectile.owner && Owner.itemAnimation % 5 == 3 && Owner.itemAnimation < Owner.itemAnimationMax - 3)
|
||||
{
|
||||
Vector2 bloodScytheShootVelocity = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2();
|
||||
bloodScytheShootVelocity.Y *= 0.04f;
|
||||
bloodScytheShootVelocity = bloodScytheShootVelocity.SafeNormalize(Vector2.UnitY) * 50f;
|
||||
Vector2 bloodScytheSpawnPosition = Projectile.Center + bloodScytheShootVelocity.SafeNormalize(Vector2.UnitY) * 35f;
|
||||
Projectile.NewProjectile(Projectile.GetSource_FromThis(), bloodScytheSpawnPosition, bloodScytheShootVelocity, ModContent.ProjectileType<BloodScythe>(), Projectile.damage, Projectile.knockBack * 0.4f, Projectile.owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DecideCurrentState()
|
||||
{
|
||||
// Switch to the swing state as necessary.
|
||||
if (CurrentState == 0f && Owner.itemAnimation > 0 && PostSwingRepositionDelay <= 0f)
|
||||
{
|
||||
if (SwingDirection == 0f)
|
||||
SwingDirection = 1f;
|
||||
else
|
||||
SwingDirection *= -1f;
|
||||
|
||||
CurrentState = SwingState.Swinging;
|
||||
}
|
||||
|
||||
// Reset the state of the weapon if the player stops using it.
|
||||
else if (Owner.itemAnimation <= 0)
|
||||
{
|
||||
Owner.itemAnimation = 0;
|
||||
Projectile.oldPos = new Vector2[Projectile.oldPos.Length];
|
||||
|
||||
CurrentState = SwingState.Default;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Main.spriteBatch.EnterShaderRegion();
|
||||
|
||||
CalamityUtils.CalculatePerspectiveMatricies(out Matrix viewMatrix, out Matrix projectionMatrix);
|
||||
|
||||
GameShaders.Misc["CalamityMod:LinearTransformation"].UseColor(Main.hslToRgb(0.95f, 0.85f, 0.5f));
|
||||
GameShaders.Misc["CalamityMod:LinearTransformation"].UseOpacity(0f);
|
||||
GameShaders.Misc["CalamityMod:LinearTransformation"].Shader.Parameters["uWorldViewProjection"].SetValue(viewMatrix * projectionMatrix);
|
||||
GameShaders.Misc["CalamityMod:LinearTransformation"].Shader.Parameters["localMatrix"].SetValue(new Matrix()
|
||||
{
|
||||
M11 = BladeHorizontalFactor,
|
||||
M12 = 0f,
|
||||
M21 = 0f,
|
||||
M22 = 1f,
|
||||
});
|
||||
GameShaders.Misc["CalamityMod:LinearTransformation"].Apply();
|
||||
|
||||
CalamityUtils.DrawAfterimagesCentered(Projectile, 2, lightColor);
|
||||
|
||||
Main.spriteBatch.ExitShaderRegion();
|
||||
|
||||
CalamityUtils.CalculatePerspectiveMatricies(out var view, out var proj);
|
||||
CalamityShaders.PrimitiveClearShader.Parameters["uWorldViewProjection"].SetValue(view * proj);
|
||||
CalamityShaders.PrimitiveClearShader.CurrentTechnique.Passes[0].Apply();
|
||||
Filters.Scene["CalamityMod:PrimitiveClearShader"].GetShader().Shader.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
ItemLoader.OnHitNPC(Owner.ActiveItem(), Owner, target, hit, damageDone);
|
||||
NPCLoader.OnHitByItem(target, Owner, Owner.ActiveItem(), hit, damageDone);
|
||||
PlayerLoader.OnHitNPC(Owner, target, hit, damageDone);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
using System;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Items.Weapons.Melee;
|
||||
using CalamityMod.Items.Weapons.Ranged;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.Rogue;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using ReLogic.Utilities;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using static CalamityMod.CalamityUtils;
|
||||
|
||||
namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
public class BladecrestOathswordThrownBlade : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Melee";
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Melee/BladecrestOathsword";
|
||||
|
||||
public int ChargeupTime = 15;
|
||||
public int Lifetime = 100;
|
||||
public float OverallProgress => 1 - Projectile.timeLeft / (float)Lifetime;
|
||||
public float ThrowProgress => 1 - Projectile.timeLeft / (float)(Lifetime);
|
||||
public float ChargeProgress => 1 - (Projectile.timeLeft - Lifetime) / (float)(ChargeupTime);
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
|
||||
// Real variables here
|
||||
public ref float time => ref Projectile.ai[0];
|
||||
public ref float stabOrder => ref Projectile.ai[1];
|
||||
public ref NPC stabbedTarget => ref Main.npc[(int)Projectile.ai[2]];
|
||||
|
||||
public bool thrown = false;
|
||||
public int fadeOutTime = 60;
|
||||
public bool stuckInTarget = false;
|
||||
public int stuckTimer = 0;
|
||||
public bool exitedTarget = false;
|
||||
public bool stuckInGround = false;
|
||||
public Vector2 impalePos;
|
||||
public int bounces = 0;
|
||||
public bool fadingOut => Projectile.timeLeft <= (Lifetime - fadeOutTime);
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 25;
|
||||
Projectile.height = 25;
|
||||
Projectile.friendly = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.timeLeft = Lifetime + ChargeupTime;
|
||||
Projectile.DamageType = DamageClass.Melee;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
}
|
||||
|
||||
public override bool ShouldUpdatePosition()
|
||||
{
|
||||
return (ChargeProgress >= 1 && !stuckInGround && !stuckInTarget);
|
||||
}
|
||||
|
||||
//Swing animation keys
|
||||
public CurveSegment pullback = new CurveSegment(EasingType.PolyOut, 0f, 0f, MathHelper.PiOver4 * -1.2f, 2);
|
||||
public CurveSegment throwout = new CurveSegment(EasingType.PolyOut, 0.7f, MathHelper.PiOver4 * -1.2f, MathHelper.PiOver4 * 1.2f + MathHelper.PiOver2, 3);
|
||||
internal float ArmAnticipationMovement() => PiecewiseAnimation(ChargeProgress, new CurveSegment[] { pullback, throwout });
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
float playerDist = Vector2.Distance(Owner.Center, Projectile.Center);
|
||||
|
||||
Projectile.spriteDirection = Projectile.direction;
|
||||
Vector3 Light = Color.Firebrick.ToVector3();
|
||||
Lighting.AddLight(Projectile.Center, Light * 0.5f);
|
||||
|
||||
if (Projectile.timeLeft == Lifetime)
|
||||
{
|
||||
Projectile.netUpdate = true;
|
||||
|
||||
// 15NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction
|
||||
Vector2 toMouse = (Main.MouseWorld - Owner.Center).SafeNormalize(Vector2.UnitX * Owner.direction);
|
||||
Projectile.velocity = toMouse * 14;
|
||||
Projectile.Center = Owner.MountedCenter + toMouse * 12f;
|
||||
Projectile.spriteDirection = Projectile.direction;
|
||||
thrown = true;
|
||||
time = 0;
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.tileCollide = true;
|
||||
}
|
||||
|
||||
if (Projectile.velocity.X > 0)
|
||||
Projectile.direction = 1;
|
||||
else
|
||||
Projectile.direction = -1;
|
||||
|
||||
if (thrown)
|
||||
{
|
||||
Projectile.spriteDirection = Projectile.direction;
|
||||
|
||||
if (!stuckInGround && exitedTarget)
|
||||
Projectile.rotation += (0.35f * (MathF.Abs(Projectile.velocity.Y) * 0.03f + 0.85f)) * Main.rand.NextFloat(0.7f, 1f) * Projectile.direction * Projectile.Opacity;
|
||||
else
|
||||
Projectile.rotation = (Projectile.velocity.ToRotation() + MathHelper.PiOver4 * (Projectile.direction == 1 ? 1 : 3));
|
||||
|
||||
if (time > fadeOutTime * 0.7f)
|
||||
Projectile.velocity *= 0.93f;
|
||||
|
||||
if (stuckInTarget)
|
||||
{
|
||||
Projectile.tileCollide = false;
|
||||
time--;
|
||||
Projectile.timeLeft++;
|
||||
if (stuckTimer > 0)
|
||||
stuckTimer--;
|
||||
else
|
||||
{
|
||||
Projectile.velocity *= 0.01f;
|
||||
stabbedTarget.Calamity().demonSwordImpales--;
|
||||
stuckInTarget = false;
|
||||
fadeOutEffect();
|
||||
}
|
||||
|
||||
Projectile.Center = stabbedTarget.Center + impalePos;
|
||||
if ((stabbedTarget.life <= 0 && stabbedTarget.realLife == -1) || stabbedTarget == null || Projectile.localAI[0] == 5)
|
||||
{
|
||||
Projectile.timeLeft = Lifetime;
|
||||
stabbedTarget.Calamity().demonSwordImpales--;
|
||||
stuckInTarget = false;
|
||||
exitedTarget = true;
|
||||
Projectile.tileCollide = true;
|
||||
for (int i = 0; i < Main.maxNPCs; i++)
|
||||
Projectile.localNPCImmunity[i] = 0;
|
||||
Projectile.numHits = 0;
|
||||
}
|
||||
}
|
||||
if (exitedTarget && !stuckInGround)
|
||||
{
|
||||
if (Projectile.velocity.Y < 14)
|
||||
Projectile.velocity.Y += 0.1f * (bounces > 0 ? 4 : 1);
|
||||
Projectile.ai[2] = 0;
|
||||
}
|
||||
|
||||
if (fadingOut)
|
||||
fadeOutEffect();
|
||||
}
|
||||
if (!fadingOut && !stuckInTarget && !stuckInGround && ChargeProgress >= 1)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Vector2 safeVel = Projectile.velocity.SafeNormalize(Vector2.UnitX);
|
||||
Vector2 dustVel = exitedTarget ? Vector2.One.RotatedByRandom(MathHelper.Pi) : safeVel.RotatedBy(MathHelper.ToRadians(105 * (i == 0 ? 1 : -1))).RotatedByRandom(0.1f) * Main.rand.NextFloat(3, 4);
|
||||
if (Main.rand.NextBool(3))
|
||||
{
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center + safeVel.RotatedBy(exitedTarget ? Projectile.rotation - MathHelper.ToRadians(45) : 0) * (exitedTarget ? 45 : 60), ModContent.DustType<LightDust>(), dustVel, 0, default, (exitedTarget ? 1.5f : 1) * Main.rand.NextFloat(0.8f, 0.9f));
|
||||
dust.noGravity = true;
|
||||
dust.color = Main.rand.NextBool() ? Color.Red : Color.Crimson;
|
||||
dust.noLight = true;
|
||||
dust.noLightEmittence = true;
|
||||
dust.alpha = 100;
|
||||
}
|
||||
}
|
||||
if (Main.rand.NextBool(5))
|
||||
{
|
||||
Particle spark2 = new CustomSpark(Projectile.Center, -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.2f, 0.6f), "CalamityMod/Particles/DemonSigilParticle", false, 17, Main.rand.NextFloat(0.2f, 0.3f), Color.Lerp(Color.Crimson, Color.Red, Main.rand.NextFloat(0, 0.7f)) * 0.6f, new Vector2(1, 1), true, false, Main.rand.NextFloat(-1f, 1f), false, false);
|
||||
GeneralParticleHandler.SpawnParticle(spark2);
|
||||
}
|
||||
}
|
||||
|
||||
//Anticipation animation. Make the player look like they're holding the item
|
||||
if (ChargeProgress < 1)
|
||||
{
|
||||
throwAnimation();
|
||||
if (ChargeProgress >= 0.6f && time == 0)
|
||||
{
|
||||
SoundStyle swing = new("CalamityMod/Sounds/Item/DemonSwordSwing", 2);
|
||||
SoundEngine.PlaySound(swing with { Volume = 0.65f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f) }, Projectile.Center);
|
||||
time++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
time++;
|
||||
}
|
||||
public void fadeOutEffect()
|
||||
{
|
||||
Projectile.tileCollide = false;
|
||||
if (Projectile.timeLeft > Lifetime - fadeOutTime)
|
||||
Projectile.timeLeft = Lifetime - fadeOutTime;
|
||||
Projectile.Opacity = Utils.GetLerpValue(0, Lifetime - fadeOutTime, Projectile.timeLeft, true);
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Vector2 dustVel = new Vector2(10, 10).RotatedByRandom(Math.PI) * Main.rand.NextFloat(0.2f, 1f) * Projectile.Opacity;
|
||||
if (Main.rand.NextBool(4))
|
||||
{
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<LightDust>(), dustVel, 0, default, Main.rand.NextFloat(1.1f, 1.4f));
|
||||
dust.noGravity = true;
|
||||
dust.color = Main.rand.NextBool() ? Color.Red : Color.Crimson;
|
||||
dust.noLight = true;
|
||||
dust.noLightEmittence = true;
|
||||
dust.alpha = 100;
|
||||
dust.velocity += Projectile.velocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void throwAnimation()
|
||||
{
|
||||
Owner.ChangeDir(MathF.Sign(Main.MouseWorld.X - Owner.Center.X));
|
||||
|
||||
float armRotation = ArmAnticipationMovement() * Owner.direction;
|
||||
|
||||
Owner.heldProj = Projectile.whoAmI;
|
||||
Projectile.spriteDirection = Owner.direction;
|
||||
Projectile.direction = Owner.direction;
|
||||
|
||||
Projectile.Center = Owner.MountedCenter + Vector2.UnitY.RotatedBy(armRotation * Owner.gravDir) * -45f * Owner.gravDir;
|
||||
Projectile.rotation = (-MathHelper.PiOver4 * Projectile.direction + armRotation) * Owner.gravDir;
|
||||
|
||||
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, MathHelper.Pi + armRotation);
|
||||
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
if (!exitedTarget)
|
||||
{
|
||||
SoundStyle stuck = new("CalamityMod/Sounds/Item/DemonSwordImpact", 2);
|
||||
SoundEngine.PlaySound(stuck with { Volume = 0.75f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f), MaxInstances = 3 }, Projectile.Center);
|
||||
|
||||
Projectile.ai[2] = target.whoAmI;
|
||||
|
||||
if (target.Calamity().demonSwordImpales >= 3)
|
||||
{
|
||||
float bladeValue = -1;
|
||||
Projectile ejectedBlade = null;
|
||||
for (int x = 0; x < Main.maxProjectiles; x++)
|
||||
{
|
||||
Projectile projectile = Main.projectile[x];
|
||||
if (projectile.owner == Projectile.owner && projectile.type == Projectile.type && projectile.ai[2] == Projectile.ai[2] && projectile.timeLeft > (Lifetime - fadeOutTime) && (bladeValue == -1 || bladeValue > projectile.ai[1]))
|
||||
{
|
||||
bladeValue = projectile.ai[1];
|
||||
ejectedBlade = projectile;
|
||||
}
|
||||
}
|
||||
ejectedBlade.localAI[0] = 5;
|
||||
ejectedBlade.velocity = Projectile.velocity.RotatedByRandom(0.2f);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
Particle spark2 = new SparkParticle(target.Center, Projectile.velocity.RotatedByRandom(0.6) * Main.rand.NextFloat(0.2f, 1f), false, 30, Main.rand.NextFloat(0.3f, 0.7f), Main.rand.NextBool(3) ? Color.Red : Color.Crimson);
|
||||
GeneralParticleHandler.SpawnParticle(spark2);
|
||||
|
||||
Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType<LightDust>(), Projectile.velocity.RotatedByRandom(0.4) * Main.rand.NextFloat(0.3f, 0.8f), 0, default, Main.rand.NextFloat(1.3f, 1.6f));
|
||||
dust.noGravity = true;
|
||||
dust.noLight = true;
|
||||
dust.color = Main.rand.NextBool(3) ? Color.Red : Color.Crimson;
|
||||
}
|
||||
}
|
||||
target.Calamity().demonSwordImpales++;
|
||||
|
||||
stuckInTarget = true;
|
||||
impalePos = Projectile.Center - stabbedTarget.Center;
|
||||
stuckTimer = 900;
|
||||
}
|
||||
}
|
||||
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
||||
{
|
||||
float minMult = 0.25f;
|
||||
int hitsToMinMult = 6;
|
||||
float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true);
|
||||
modifiers.SourceDamage *= damageMult * (exitedTarget ? 1.3f : 1);
|
||||
}
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
if (exitedTarget)
|
||||
{
|
||||
if (bounces >= 1)
|
||||
{
|
||||
impaleGround(oldVelocity);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Projectile.velocity.X != oldVelocity.X)
|
||||
{
|
||||
Projectile.velocity.X = -oldVelocity.X;
|
||||
}
|
||||
if (Projectile.velocity.Y != oldVelocity.Y)
|
||||
{
|
||||
Projectile.velocity.Y = -oldVelocity.Y;
|
||||
}
|
||||
if (Projectile.velocity.Length() < 8)
|
||||
Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 8;
|
||||
Projectile.velocity.Y *= 0.85f;
|
||||
SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/CeramicImpact", 2) { Volume = 0.35f, Pitch = Main.rand.NextFloat(-0.4f, -0.5f) }, Projectile.Center);
|
||||
bounces++;
|
||||
Projectile.timeLeft = Lifetime;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
impaleGround(oldVelocity);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public void impaleGround(Vector2 oldVelocity)
|
||||
{
|
||||
Projectile.velocity = oldVelocity;
|
||||
stuckInGround = true;
|
||||
Projectile.timeLeft = (int)(Lifetime - fadeOutTime * 0.3f);
|
||||
Projectile.tileCollide = false;
|
||||
SoundStyle stuck = new("CalamityMod/Sounds/Item/DemonSwordImpact", 2);
|
||||
SoundEngine.PlaySound(stuck with { Volume = 0.75f, Pitch = Main.rand.NextFloat(0.2f, 0.3f), MaxInstances = 3 }, Projectile.Center);
|
||||
}
|
||||
public override bool? CanDamage()
|
||||
{
|
||||
if (ChargeProgress < 1 || fadingOut || stuckInGround || stuckInTarget)
|
||||
return false;
|
||||
|
||||
return base.CanDamage();
|
||||
}
|
||||
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width / (exitedTarget ? 1 : 2), targetHitbox); // After exiting a target, the hitbox is larger
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D centerTexture = ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/Melee/BladecrestOathsword").Value;
|
||||
Vector2 generalDrawPos = Projectile.Center - Main.screenPosition;
|
||||
|
||||
float fadeScale = (1 - Projectile.Opacity);
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
Color auraColor = Color.Crimson with { A = 0 } * 0.4f * fadeScale * Projectile.Opacity;
|
||||
Vector2 drawOffset = (MathHelper.TwoPi * i / 16f).ToRotationVector2() * 9 * fadeScale;
|
||||
Main.EntitySpriteDraw(centerTexture, Projectile.Center - Main.screenPosition + drawOffset, null, auraColor, Projectile.rotation, centerTexture.Size() * 0.5f, Projectile.scale, Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally);
|
||||
}
|
||||
|
||||
Main.EntitySpriteDraw(centerTexture, Projectile.Center - Main.screenPosition, null, Color.Lerp(Color.Red with { A = 0 }, lightColor, Projectile.Opacity) * Projectile.Opacity, Projectile.rotation, centerTexture.Size() * 0.5f, Projectile.scale, Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user