Relic of Deliverance

I'm so so so so so so so so tired
This commit is contained in:
Xyk committed 2024-11-04 06:34:14 -08:00
1 parent e9a4426fa8
commit f32d9c3e45
6 files changed
+378 -176

No files matched your search

@@ -390,10 +390,10 @@ RelicOfConvergence: {
DisplayName: Relic of Convergence
Tooltip:
'''
Creates a profaned crystal that channels healing energy at your cursor
Once fully channeled, all players within the area of effect are healed for {0} HP
Players other than yourself gain 50% extra healing
Holding out the crystal heavily reduces the damage of all summons
Creates a profaned crystal that channels healing energy at your cursor
Once fully channeled, all players within the area of effect are healed for {0} HP
Players other than yourself gain 50% extra healing
Holding out the crystal heavily reduces the damage of all summons
'''
}
@@ -30,10 +30,10 @@ RelicOfDeliverance: {
DisplayName: Relic of Deliverance
Tooltip:
'''
Press <left> to begin charging up a lunging spear attack
Press <left> again to release the charge and lunge towards the cursor
Pressing <left> while lunging to redirect the lunge to the cursor
Holding any other item will cancel the charge
Press <left> to grab hold of the spear and steer it
Press <left> again to while flying on the spear to drift, slowing your velocity but charging an extremley fast dash released when you let go of <left>
If you loose too much velocity before releasing the charge, you will reset to minimum speed
The spear can take you through walls but will warp you to the last open space if you are inside them too long
'''
}
@@ -183,18 +183,6 @@ namespace CalamityMod.Projectiles.Typeless
Vector2 drawPosition = (time >= CrystalsDrawTime ? Projectile.Center : Projectile.Center + drawPositionOffset + Main.rand.NextVector2Circular(12, 12));
Projectile.DrawProjectileWithBackglow(Color.Lerp(Color.Orchid, Color.Goldenrod, fade) with { A = 0 } * completion * 0.5f, Color.Lerp(Color.White, Color.White with { A = 0 }, fade * 0.5f) * MathHelper.Clamp(completion * 1.5f, time >= CrystalsDrawTime ? 0.8f : 0f, 1), 4f * completion + (fade * 3), crystalTexture, xPos: drawPosition.X, yPos: drawPosition.Y);
/*
Main.EntitySpriteDraw(crystalTexture,
drawPosition - Main.screenPosition,
null,
Color.White * opacity,
Projectile.rotation,
Projectile.Size * 0.5f,
Projectile.scale,
SpriteEffects.None,
0);
*/
}
return false;
}
+370 -156
View File
@@ -1,9 +1,15 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection.Metadata;
using CalamityMod.CalPlayer;
using CalamityMod.Dusts;
using CalamityMod.Items.Weapons.Typeless;
using CalamityMod.Particles;
using Microsoft.CodeAnalysis;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using ReLogic.Utilities;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
@@ -15,13 +21,36 @@ namespace CalamityMod.Projectiles.Typeless
public class RelicOfDeliveranceSpear : ModProjectile
{
public override LocalizedText DisplayName => CalamityUtils.GetItemName<RelicOfDeliverance>();
public Vector2 IdealVelocity = -Vector2.UnitY * MinChargeSpeed;
public const int MaxCharges = 3;
public const float DustSpawnInterval = 3f;
public const float WaitTimeRequiredForCharge = 40f;
public const float WaitTimeRequiredForMaximumCharge = 180f;
public const float MinChargeSpeed = 16f;
public const float MaxChargeSpeed = 30f;
public ref float time => ref Projectile.ai[0];
public Vector2 idealVel;
public int driftFrames = 0;
public bool flying = false;
public Player Owner => Main.player[Projectile.owner];
public int boostTimer = 0;
public bool boosted => boostTimer > 0;
public int driftTimer = 0;
public bool drifting => Main.mouseLeft;
public int driftPower = 1;
public float driftPowerScaling = 1;
public float driftBadMult = 1;
public bool killed = false;
public float velX;
public float velY;
public Vector2 respawnPoint;
public int respawnTimer = 0;
public bool inTiles = false;
public float respawnMult = 0;
int postHitTimer = 0;
public Color bColor = Color.White;
public SlotId digSoundSlot;
public int digFXCooldown = 0;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 5;
@@ -36,37 +65,36 @@ namespace CalamityMod.Projectiles.Typeless
Projectile.penetrate = -1;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 8;
Projectile.localNPCHitCooldown = 20;
Projectile.extraUpdates = 25;
}
public override void SendExtraAI(BinaryWriter writer)
{
writer.Write(Projectile.localAI[0]);
writer.Write(Projectile.localAI[1]);
writer.WriteVector2(IdealVelocity);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
Projectile.localAI[0] = reader.ReadSingle();
Projectile.localAI[1] = reader.ReadSingle();
IdealVelocity = reader.ReadVector2();
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
if (player.dead ||
Projectile.Center.Y < 200f ||
Projectile.Center.X < 200f ||
Projectile.Center.X > Main.maxTilesX * 16f - 200f)
{
Projectile.Kill();
if (killed)
return;
float rate = Main.GlobalTimeWrappedHourly * 7;
List<Color> eColors = new List<Color>()
{
Color.Goldenrod,
Color.OrangeRed,
Color.Orange,
Color.Gold
};
int colorIndex = (int)(rate / 2 % eColors.Count);
Color currentColor = eColors[colorIndex];
Color nextColor = eColors[(colorIndex + 1) % eColors.Count];
bColor = Color.Lerp(currentColor, nextColor, rate % 2f > 1f ? 1f : rate % 1f);
if (Owner.dead || Owner.Calamity().mouseRight || !WorldGen.InWorld(Owner.Center.ToTileCoordinates().X, Owner.Center.ToTileCoordinates().Y, 20)) // Die if Owner dies or right clicks to exit
{
KillProj();
}
Projectile.frameCounter++;
if (Projectile.frameCounter > 4)
if (Projectile.frameCounter > 4 * Projectile.MaxUpdates)
{
Projectile.frame++;
Projectile.frameCounter = 0;
@@ -75,170 +103,356 @@ namespace CalamityMod.Projectiles.Typeless
{
Projectile.frame = 0;
}
Projectile.ai[0]++;
if (Projectile.velocity == Vector2.Zero)
// Immediately die if the Owner is not holding the spear
if (Owner.ActiveItem() == null)
{
// Immediately die if the player is not holding the spear
if (player.ActiveItem() == null)
KillProj();
return;
}
if (Owner.ActiveItem().type != ModContent.ItemType<RelicOfDeliverance>())
{
KillProj();
return;
}
float speed = (CalamityPlayer.areThereAnyDamnBosses ? 3f : 6f) * driftBadMult * (inTiles ? 0.65f : 1);
Vector2 aimDir = Owner.Calamity().mouseWorld;
idealVel = Utils.DirectionTo(Owner.Center, aimDir) * speed * driftPower;
driftPowerScaling = MathHelper.Lerp(driftPowerScaling, driftPower * 0.7f, 0.005f);
if (time == 0)
{
Projectile.velocity = idealVel * 0.2f;
velX = Projectile.velocity.X;
velY = Projectile.velocity.Y;
}
float lerpPower = (drifting ? 0 : (boosted && driftPower > 1) ? 0.01f * Utils.GetLerpValue(120 * driftPower, 0, boostTimer) : 0.02f);
velX = MathHelper.Lerp(Projectile.velocity.X, idealVel.X, lerpPower);
velY = MathHelper.Lerp(Projectile.velocity.Y, idealVel.Y, lerpPower);
Projectile.velocity = new Vector2(velX, velY);
if (Projectile.velocity.Length() <= speed && !drifting)
{
Projectile.velocity *= 1.05f;
}
if (drifting)
{
if (driftTimer == 0)
driftPower = 1;
boostTimer = 0;
if (time % Projectile.MaxUpdates == 0)
{
Projectile.Kill();
return;
}
if (player.ActiveItem().type != ModContent.ItemType<RelicOfDeliverance>())
{
Projectile.Kill();
return;
}
Projectile.rotation = Projectile.AngleTo(Main.MouseWorld);
Projectile.Center = player.Center;
if (Projectile.ai[0] >= WaitTimeRequiredForCharge)
{
// Begin the lunge
bool noObstaclesInWay = Collision.CanHitLine(Projectile.Center, 1, 1, Projectile.Center + Projectile.SafeDirectionTo(Main.MouseWorld) * 25f, 1, 1);
if (Main.myPlayer == Projectile.owner && Main.mouseLeft && !Main.blockMouse && !player.mouseInterface && noObstaclesInWay)
if (Projectile.velocity.Length() > 1)
{
float chargeSpeed = MathHelper.Lerp(MinChargeSpeed, MaxChargeSpeed, (Projectile.ai[0] - WaitTimeRequiredForCharge) / WaitTimeRequiredForMaximumCharge);
if (chargeSpeed > MaxChargeSpeed)
chargeSpeed = MaxChargeSpeed;
Projectile.velocity = Projectile.SafeDirectionTo(Main.MouseWorld) * chargeSpeed;
IdealVelocity = Projectile.velocity;
Projectile.ai[1] = chargeSpeed;
SoundEngine.PlaySound(SoundID.Item73, Projectile.Center);
Projectile.netUpdate = true;
driftBadMult = 1;
driftTimer++;
driftPower = (driftTimer > 100 ? 3 : driftTimer > 40 ? 2 : 1);
}
// Charge-up dust
if (Projectile.ai[0] <= WaitTimeRequiredForCharge + WaitTimeRequiredForMaximumCharge)
else
{
for (int i = 0; i < 3; i++)
driftPower = 1;
driftTimer = (int)(MathHelper.Clamp(driftTimer * 0.94f, 1, 300));
}
Projectile.velocity *= 0.98f;
}
Projectile.extraUpdates = 3;
float sparkPower = Utils.GetLerpValue(0, 100, driftTimer);
if (time % Projectile.extraUpdates * 2 == 0)
{
SoundStyle sound = new("CalamityMod/Sounds/Item/NullImpact");
SoundEngine.PlaySound(sound with { Volume = 0.045f, Pitch = (Main.rand.NextFloat(-0.2f, -0.4f) + sparkPower * 0.4f) + (driftPower == 2 ? 0.3f : driftPower == 3 ? 0.7f : 0), MaxInstances = -1 }, Projectile.Center);
}
for (int i = 0; i < 2; i++)
{
Color sparkColor = (driftPower == 2 ? Color.Orange : driftPower == 3 ? Color.OrangeRed : Color.Khaki);
Vector2 baseVel = Vector2.Lerp(Projectile.velocity, -idealVel, sparkPower);
Vector2 vel = baseVel.RotatedByRandom(1.5f - sparkPower * 0.5f) * Main.rand.NextFloat(0.5f, 3f);
Particle energy = new VelChangingSpark(Projectile.Center + idealVel * 3, vel + baseVel.SafeNormalize(Vector2.UnitX) * 15, vel, "CalamityMod/Particles/BloomCircle", Main.rand.Next(6, 9 + 1), Main.rand.NextFloat(0.25f, 0.65f) * sparkPower, Color.Lerp(sparkColor, Color.Goldenrod, Main.rand.NextFloat(0, 0.3f)), new Vector2(0.2f, 1f), lerpRate: 0.35f, shrinkSpeed: 0.3f);
GeneralParticleHandler.SpawnParticle(energy);
}
}
if (!drifting)
{
if (driftPower > 2)
Projectile.extraUpdates = 5;
else
Projectile.extraUpdates = 3;
if (driftPower == 1 && driftBadMult == 1 && driftTimer > 0)
{
Projectile.velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) * (speed * 0.1f);
driftBadMult = 0.1f;
}
if (time % Projectile.MaxUpdates == 0)
{
if (driftBadMult < 1)
driftBadMult += 0.005f;
if (boostTimer == 0 && driftTimer > 0)
{
driftBadMult = (driftPower > 1 ? 1 : time < 60 ? 0 : 0.35f);
driftTimer = 0;
Projectile.velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) * speed * driftPower;
Particle pulse2 = new CustomPulse(Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3.1f * driftPower, Color.Goldenrod * 0.8f, "CalamityMod/Particles/BloomRing", new Vector2(0.4f, 1f), Projectile.velocity.ToRotation(), 0f, 1.33f * driftPower, 25);
GeneralParticleHandler.SpawnParticle(pulse2);
Particle pulse = new CustomPulse(Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.UnitX) * 8.4f * driftPower, Color.OrangeRed * 0.8f, "CalamityMod/Particles/BloomRing", new Vector2(0.4f, 1f), Projectile.velocity.ToRotation(), 0f, 0.92f * driftPower, 25);
GeneralParticleHandler.SpawnParticle(pulse);
float volume = 0.1f + 0.3f * driftPower;
SoundStyle sound = new("CalamityMod/Sounds/Item/HolyColliderSmallHit");
SoundEngine.PlaySound(sound with { Volume = volume, Pitch = (-0.7f + 0.1f * driftPower) }, Projectile.Center);
if (driftPower > 1)
{
Vector2 dustPosition = Utils.NextVector2Circular(Main.rand, Projectile.width * 1.6f, Projectile.height * 2.3f) / 2f + Projectile.Center;
Dust dust = Dust.NewDustPerfect(dustPosition, (int)CalamityDusts.ProfanedFire);
dust.velocity = Projectile.SafeDirectionTo(dust.position) * Projectile.Distance(dust.position) / -11f;
dust.velocity += player.velocity;
dust.noGravity = true;
dust.fadeIn = 1.6f;
SoundStyle sound2 = new("CalamityMod/Sounds/Item/LauncherHeavyShot");
SoundEngine.PlaySound(sound2 with { Volume = volume * 2, Pitch = (-0.3f - 0.1f * driftPower) }, Projectile.Center);
}
Projectile.Center += Utils.NextVector2Circular(Main.rand, 1.8f, 1.8f);
}
// Full charge dust indicator
if (Projectile.ai[0] == WaitTimeRequiredForCharge + WaitTimeRequiredForMaximumCharge)
{
for (int i = 0; i < 60; i++)
if (driftPower > 2)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, (int)CalamityDusts.ProfanedFire);
dust.velocity = Utils.NextVector2Circular(Main.rand, 9f, 9f) * Main.rand.NextFloat(0.8f, 1.2f);
dust.velocity += player.velocity;
dust.noGravity = true;
dust.fadeIn = 1.6f;
SoundStyle sound3 = new("CalamityMod/Sounds/Item/OpalChargedFire");
for (int i = 0; i < 3; i++)
SoundEngine.PlaySound(sound3 with { Volume = 0.7f, Pitch = 0.4f, MaxInstances = 3 }, Projectile.Center);
}
SoundEngine.PlaySound(SoundID.DD2_DarkMageHealImpact, Projectile.Center);
if (driftPower > 1)
Owner.Calamity().GeneralScreenShakePower = (driftPower == 2 ? 6 : 9);
boostTimer = 120 * driftPower;
}
player.ChangeDir((Math.Cos(Projectile.rotation) > 0).ToDirectionInt());
if (boostTimer > 0)
boostTimer--;
if (boostTimer == 0)
driftPower = 1;
}
if (driftBadMult > 0.2f)
{
float sine = (float)Math.Sin(time * 0.085f / MathHelper.Pi);
float mult = driftBadMult * driftPowerScaling;
Vector2 tipPos = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 125 * mult;
Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 15.5f;
for (int i = 0; i < 2; i++)
{
offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * 15.5f * (i == 0 ? -1 : 1);
Particle spark = new VelChangingSpark(tipPos + offset, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) + offset * 0.05f) * 20.5f * mult, -Projectile.velocity.SafeNormalize(Vector2.UnitX), "CalamityMod/Particles/SmallBloom", 15, 0.11f * mult, bColor * 0.65f, new Vector2(1, 3.8f), true, false, shrinkSpeed: 0.42f, lerpRate: 0.4f);
GeneralParticleHandler.SpawnParticle(spark);
}
if (driftPower == 3)
{
Vector2 vel = Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1, 10);
Particle energy = new VelChangingSpark(Projectile.Center + vel, -Projectile.velocity.SafeNormalize(Vector2.UnitX), -Projectile.velocity.SafeNormalize(Vector2.UnitX) + vel * Main.rand.NextFloat(0.01f, 0.02f), "CalamityMod/Particles/BloomCircle", Main.rand.Next(12, 19 + 1), Main.rand.NextFloat(0.55f, 0.95f), Color.Lerp(Color.OrangeRed, Color.Goldenrod, Main.rand.NextFloat(0, 1f)), new Vector2(0.2f, 1f), lerpRate: 0.25f, shrinkSpeed: 0.35f);
GeneralParticleHandler.SpawnParticle(energy);
}
if (time % Projectile.MaxUpdates == 0)
{
Vector2 vel = (Projectile.velocity.SafeNormalize(Vector2.UnitX) + (offset * (Main.rand.NextBool() ? 1 : -1)) * 0.03f) * 50.5f * mult;
Dust dust2 = Dust.NewDustPerfect(Projectile.Center + (offset * (Main.rand.NextBool() ? 1 : -1)).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.6f, 1.4f), ModContent.DustType<LightDust>());
dust2.scale = Main.rand.NextFloat(0.7f, 1.2f) * mult;
dust2.noGravity = true;
dust2.velocity = vel * Main.rand.NextFloat(0.6f, 1.4f);
dust2.color = bColor;
}
}
}
if (Collision.SolidCollision(Projectile.Center, 20, 20))
inTiles = true;
else
inTiles = false;
if (inTiles)
{
if (respawnTimer == 0 && time % Projectile.MaxUpdates == 0)
{
SoundStyle digSound = new("CalamityMod/Sounds/Item/HeavyDig");
digSoundSlot = SoundEngine.PlaySound(digSound with { Volume = 0.7f, IsLooped = true }, Projectile.Center);
if (digFXCooldown == 0)
{
SoundStyle sound = new("CalamityMod/Sounds/Item/MagicRockImpact");
SoundEngine.PlaySound(sound with { Volume = 0.4f, Pitch = Main.rand.NextFloat(0.3f, 0.7f) }, Projectile.Center);
for (int i = 0; i < 13; i++)
{
Particle spark = new CustomSpark(Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.6f) * Main.rand.NextFloat(2f, 24f), "CalamityMod/Projectiles/Typeless/ArtifactOfResilienceShard6", true, Main.rand.Next(25, 35 + 1), Main.rand.NextFloat(0.85f, 2.3f), Color.White, new Vector2(1.1f, 0.8f), false, false, Main.rand.NextFloat(-5, 5), false, false);
GeneralParticleHandler.SpawnParticle(spark);
if (i % 2 == 0)
{
MediumMistParticle RockCloud = new MediumMistParticle(Projectile.Center + Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1f, 7f), -Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.6f) * Main.rand.NextFloat(1, 12), Color.Peru, Color.Sienna, Main.rand.NextFloat(1.4f, 2.3f), 120f, Main.rand.NextFloat(0.03f, -0.03f));
GeneralParticleHandler.SpawnParticle(RockCloud);
}
}
digFXCooldown = 5;
}
}
if (time % Projectile.MaxUpdates == 0)
respawnTimer++;
if (respawnTimer >= 180 && respawnPoint != Vector2.Zero)
{
Projectile.Center = respawnPoint;
Owner.Center = respawnPoint;
Projectile.velocity *= 0.01f;
for (int i = 0; i < 15; i++)
{
Vector2 vel = (MathHelper.TwoPi * i / 15f).ToRotationVector2() * 15.5f * (i % 4 == 0 ? 0.88f : 1f) * Main.rand.NextFloat(0.8f, 1f);
float scale = Main.rand.NextFloat(1.3f, 1.6f) * 0.6f * (i % 4 == 0 ? 2.2f : 1.8f);
Particle aura = new VelChangingSpark(respawnPoint, vel.RotatedBy(0.02f) * 3, -vel.RotatedBy(-0.04f) * 4, "CalamityMod/Particles/SmallBloom", 27, 0.2f, Color.Goldenrod, new Vector2(1.8f, 1.5f), lerpRate: 0.07f, shrinkSpeed: 0.25f);
GeneralParticleHandler.SpawnParticle(aura);
}
Particle orb2 = new CustomPulse(respawnPoint, Vector2.Zero, Color.Khaki, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 2, 0.5f, 28);
GeneralParticleHandler.SpawnParticle(orb2);
SoundStyle sound = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianHeal");
SoundEngine.PlaySound(sound with { Volume = 0.6f, Pitch = Main.rand.NextFloat(-0.7f, -0.9f) }, respawnPoint);
KillProj();
}
if (SoundEngine.TryGetActiveSound(digSoundSlot, out var zound) && zound.IsPlaying)
{
zound.Position = Projectile.Center;
zound.Pitch = 0.4f * respawnMult - (drifting ? 0.5f : 0);
zound.Volume = (drifting ? 0.6f : 1f);
}
respawnMult = Utils.GetLerpValue(60, 180, respawnTimer);
}
else
{
// Adjust direction so that the spear is always launching in the direction of the mouse.
// However, if the mouse position is really close to the projectile, don't do anything.
// Being close to the target may cause erratic movements.
// The projectile.localAI[1] part is to prevent the projectile from redirecting on a frame-by-frame basis (Main.mouseLeft seems to mean mouse hold, not release).
if (Projectile.Distance(Main.MouseWorld) > 60f &&
Main.mouseLeft && !Main.blockMouse && !player.mouseInterface &&
Projectile.localAI[0] <= MaxCharges &&
Projectile.localAI[1] <= 0f)
if (SoundEngine.TryGetActiveSound(digSoundSlot, out var zound))
zound?.Stop();
respawnPoint = Projectile.Center;
if (respawnTimer > 0)
{
IdealVelocity = Projectile.SafeDirectionTo(Main.MouseWorld) * Projectile.ai[1];
Projectile.localAI[0]++;
Projectile.localAI[1] = 40f;
SoundEngine.PlaySound(SoundID.Item73, Projectile.Center);
Projectile.netUpdate = true;
}
else if (Projectile.localAI[0] > MaxCharges)
{
if (Projectile.timeLeft > 120)
if (digFXCooldown == 0)
{
Projectile.timeLeft = 120;
SoundStyle sound = new("CalamityMod/Sounds/Item/MagicRockSound");
SoundEngine.PlaySound(sound with { Volume = 0.4f, Pitch = Main.rand.NextFloat(0.3f, 0.7f) }, Projectile.Center);
for (int i = 0; i < 13; i++)
{
Particle spark = new CustomSpark(Projectile.Center, Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.6f) * Main.rand.NextFloat(2f, 24f), "CalamityMod/Projectiles/Typeless/ArtifactOfResilienceShard6", true, Main.rand.Next(25, 35 + 1), Main.rand.NextFloat(0.85f, 2.3f), Color.White, new Vector2(1.1f, 0.8f), false, false, Main.rand.NextFloat(-5, 5), false, false);
GeneralParticleHandler.SpawnParticle(spark);
if (i % 2 == 0)
{
MediumMistParticle RockCloud = new MediumMistParticle(Projectile.Center + Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1f, 7f), Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.6f) * Main.rand.NextFloat(1, 12), Color.Peru, Color.Sienna, Main.rand.NextFloat(1.4f, 2.3f), 120f, Main.rand.NextFloat(0.03f, -0.03f));
GeneralParticleHandler.SpawnParticle(RockCloud);
}
}
digFXCooldown = 5;
}
Projectile.alpha = (int)MathHelper.Lerp(0, 255, 1f - Projectile.timeLeft / 120f);
}
if (Projectile.velocity != IdealVelocity)
{
Projectile.velocity = Vector2.Lerp(Projectile.velocity, IdealVelocity, 0.125f);
}
respawnTimer = 0;
respawnMult = 0f;
player.velocity = Projectile.velocity;
// Count down the charge cooldown
if (Projectile.localAI[1] > 0f)
Projectile.localAI[1]--;
Projectile.rotation = Projectile.velocity.ToRotation();
// Player manipulations (setting the center point and disallowing mounts).
player.Center = Projectile.Center;
// Adjust the player's held projectile type.
if (player.heldProj == -1)
player.heldProj = Projectile.whoAmI;
player.mount?.Dismount(player);
player.ChangeDir(Math.Sign(Projectile.velocity.X) <= 0 ? -1 : 1);
// Generate dust
if (Projectile.ai[0] % DustSpawnInterval == DustSpawnInterval - 1f)
if (time % Projectile.extraUpdates * 2 == 0 && !drifting)
{
for (int i = 0; i < 12; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center + (Projectile.Size / 2f).RotatedBy(Projectile.rotation), (int)CalamityDusts.ProfanedFire);
dust.velocity = Projectile.velocity.RotatedBy(MathHelper.ToRadians(20f * (i % 2 == 0).ToDirectionInt()));
dust.noGravity = true;
dust.fadeIn = 1.8f;
}
SoundStyle sound = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianDash");
SoundEngine.PlaySound(sound with { Volume = 0.065f * driftPowerScaling, Pitch = Main.rand.NextFloat(-0.4f, -0.9f) + (driftPower == 3 ? 1.4f : 0), MaxInstances = -1 }, Owner.Center);
}
}
// Don't die when colliding with tiles unless the spear is lunging (and after a bit of time has passed).
Projectile.tileCollide = Projectile.velocity != Vector2.Zero && Projectile.ai[0] >= WaitTimeRequiredForCharge + 10f;
if (time % Projectile.extraUpdates == 0 && digFXCooldown > 0)
digFXCooldown--;
// Die immediately if the owner of this projectile is clipping into tiles because of its movement.
if (Collision.SolidCollision(player.position, player.width, player.height) && Projectile.velocity != Vector2.Zero)
Owner.Center = Projectile.Center;
Owner.velocity = Projectile.velocity * Projectile.MaxUpdates;
Owner.dashDelay = 0;
Projectile.timeLeft++;
Lighting.AddLight(Projectile.Center, Color.Gold.ToVector3() * (driftPowerScaling + 0.5f));
Owner.mount?.Dismount(Owner);
Owner.ChangeDir(Math.Sign(drifting ? idealVel.X : Projectile.velocity.X) <= 0 ? -1 : 1);
if (!killed)
{
player.velocity.Y = 0f;
DoDeathDust(Projectile.oldVelocity);
float idealRot = (drifting ? idealVel : Projectile.velocity).ToRotation();
Projectile.rotation = Utils.AngleLerp(Projectile.rotation, idealRot, (boostTimer > 0 ? 1 : 0.15f));
Owner.fullRotationOrigin = Owner.Center - Owner.position;
Owner.fullRotation = (Owner.direction == -1 ? MathHelper.ToRadians(180f) : 0) + Projectile.rotation + MathHelper.ToRadians(65f * Owner.direction);
float rot = (drifting ? idealVel : Projectile.velocity).ToRotation() + (Owner.direction == -1 ? MathHelper.ToRadians(270f) : MathHelper.ToRadians(-90f));
Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rot - Owner.fullRotation);
Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, rot - Owner.fullRotation);
Projectile.Kill();
}
Lighting.AddLight(Projectile.Center, Color.LightGoldenrodYellow.ToVector3());
time++;
// I pray for the fate of this thing in multiplayer dear god
Projectile.netUpdate = true;
Projectile.netSpam = 0;
}
public void DoDeathDust(Vector2 oldVelocity)
public void KillProj()
{
if (Main.dedServ)
return;
if (SoundEngine.TryGetActiveSound(digSoundSlot, out var sound))
sound?.Stop();
for (int i = 0; i < 60; i++)
if (inTiles && respawnPoint != Vector2.Zero)
{
Vector2 spawnOffset = (Projectile.Size / 2f).RotatedBy(Projectile.rotation);
spawnOffset += Utils.NextVector2Circular(Main.rand, 10f, 10f);
Dust dust = Dust.NewDustPerfect(Projectile.Center + spawnOffset, (int)CalamityDusts.ProfanedFire);
dust.velocity = Utils.NextVector2Circular(Main.rand, 5f, 5f) + oldVelocity;
dust.noGravity = true;
dust.fadeIn = 1.9f;
Projectile.Center = respawnPoint;
Owner.Center = respawnPoint;
}
SoundEngine.PlaySound(SoundID.Item14, Projectile.Center);
killed = true;
Owner.fullRotationOrigin = Owner.Center - Owner.position;
Owner.fullRotation = 0;
Projectile.Kill();
}
public override bool? CanDamage() => Projectile.velocity != Vector2.Zero ? null : false;
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
float damageMult = driftPowerScaling * 1.4f; // Drift power scaling is lower than regular
modifiers.SourceDamage *= damageMult;
}
public override bool? CanDamage() => (Projectile.velocity == Vector2.Zero || drifting) ? false : null;
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 30, 50, targetHitbox);
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
Vector2 drawPos = Owner.MountedCenter + (drifting ? idealVel : Projectile.velocity).SafeNormalize(Vector2.UnitX) * (55 - 35 * Utils.GetLerpValue(0, 25, driftTimer, true));
Projectile.DrawProjectileWithBackglow(Color.Goldenrod with { A = 0 }, Color.White, 3f * driftPowerScaling, effects: Math.Sign((drifting ? idealVel.X : Projectile.velocity.X)) == -1 ? Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically : Microsoft.Xna.Framework.Graphics.SpriteEffects.None, xPos: drawPos.X, yPos: drawPos.Y);
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomRing").Value;
Texture2D texture2 = ModContent.Request<Texture2D>("CalamityMod/Particles/GlowSpark").Value;
Texture2D texture3 = ModContent.Request<Texture2D>("CalamityMod/Particles/HalfStar").Value;
if (inTiles)
{
float randSize = Main.rand.NextFloat(0.9f, 1.1f);
Vector2 vel = Utils.DirectionTo(Projectile.Center, respawnPoint);
for (int i = 0; i < 4; i++)
Main.EntitySpriteDraw(texture2, Projectile.Center - Main.screenPosition + vel * 80 * respawnMult, null, Color.Goldenrod with { A = 0 } * respawnMult, vel.ToRotation() + MathHelper.ToRadians(90f), texture2.Size() * 0.5f, new Vector2(1.2f - i * 0.2f, (1.2f + i * 0.3f) * respawnMult) * (0.7f + i * 0.07f) * 0.05f, SpriteEffects.None, 0);
for (int i = 0; i < 3; i++)
Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, (i == 0 ? Color.White : Color.Goldenrod) with { A = 0 } * respawnMult, vel.ToRotation(), texture.Size() * 0.5f, (0.43f + i * 0.08f) * respawnMult, SpriteEffects.None, 0);
for (int i = 0; i < 2; i++)
{
Main.EntitySpriteDraw(texture, respawnPoint - Main.screenPosition, null, bColor with { A = 0 } * MathHelper.Clamp(respawnMult + 0.5f, 0.5f, 1), vel.ToRotation(), texture.Size() * 0.5f, 0.15f + respawnMult * 0.5f, SpriteEffects.None, 0);
Main.EntitySpriteDraw(texture3, respawnPoint - Main.screenPosition, null, bColor with { A = 0 }, i == 0 ? MathHelper.ToRadians(90f) : 0, texture3.Size() * 0.5f, new Vector2(0.8f, 1.5f) * 1.65f * randSize, SpriteEffects.None, 0);
Main.EntitySpriteDraw(texture3, respawnPoint - Main.screenPosition, null, Color.White with { A = 0 } * 0.65f, i == 0 ? MathHelper.ToRadians(90f) : 0, texture3.Size() * 0.5f, new Vector2(0.8f, 1.5f) * 1.25f * randSize, SpriteEffects.None, 0);
}
}
if (!drifting)
{
Vector2 placement = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * (-20 + 80 * (driftPowerScaling <= 1 ? driftPowerScaling : 1));
Asset<Texture2D> tex = ModContent.Request<Texture2D>("CalamityMod/Particles/VerticalSmear");
Asset<Texture2D> tex2 = ModContent.Request<Texture2D>("CalamityMod/Particles/SemiCircularSmearSwipe");
for (int i = 0; i < 6; i++)
{
Vector2 scale = new Vector2(0.5f - i * 0.1f, (1.5f + i * 0.15f) * driftBadMult) * (0.75f * driftPowerScaling * Main.rand.NextFloat(0.9f, 1.1f) + 0.25f);
Main.EntitySpriteDraw(tex.Value, placement - Main.screenPosition, null, bColor with { A = 0 } * 0.5f * driftBadMult, Projectile.rotation + MathHelper.ToRadians(90f), tex.Size() * 0.5f, scale, SpriteEffects.None);
}
}
return false;
}
// Force the spear to have "priority" when drawing so that it draws over the player.
// Force the spear to have "priority" when drawing so that it draws over the Owner.
public override void DrawBehind(int index, List<int> behindNPCsAndTiles, List<int> behindNPCs, List<int> behindProjectiles, List<int> overPlayers, List<int> overWiresUI)
{
overWiresUI.Add(index);
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
DoDeathDust(oldVelocity);
return base.OnTileCollide(oldVelocity);
}
}
}
Binary file not shown.
Binary file not shown.