2 - Changed Elemental Lance a lot. 3 - Removed Iridescent Excalibur healing because it was buggy (I'll add it again later for the true melee projectile).
113 lines
4.1 KiB
C#
113 lines
4.1 KiB
C#
using System;
|
|
using CalamityMod.Buffs.DamageOverTime;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Melee
|
|
{
|
|
public class SpatialSpear4 : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Melee";
|
|
|
|
private const int TimeLeft = 60;
|
|
|
|
private const int TimeToFall = TimeLeft / 2;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 1;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 16;
|
|
Projectile.height = 16;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Melee;
|
|
Projectile.timeLeft = TimeLeft;
|
|
Projectile.usesIDStaticNPCImmunity = true;
|
|
Projectile.idStaticNPCHitCooldown = 10;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(Projectile.Center, 0.5f, 0.5f, 0.05f);
|
|
|
|
Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver4;
|
|
|
|
if (Projectile.timeLeft < TimeToFall)
|
|
{
|
|
Projectile.velocity.Y += 0.16f;
|
|
if (Projectile.velocity.Y > 16f)
|
|
Projectile.velocity.Y = 16f;
|
|
|
|
Projectile.velocity.X *= 0.995f;
|
|
}
|
|
|
|
if (Projectile.localAI[1] == 0f)
|
|
{
|
|
Projectile.scale -= 0.01f;
|
|
Projectile.alpha += 15;
|
|
if (Projectile.alpha >= 125)
|
|
{
|
|
Projectile.alpha = 130;
|
|
Projectile.localAI[1] = 1f;
|
|
}
|
|
}
|
|
else if (Projectile.localAI[1] == 1f)
|
|
{
|
|
Projectile.scale += 0.01f;
|
|
Projectile.alpha -= 15;
|
|
if (Projectile.alpha <= 0)
|
|
{
|
|
Projectile.alpha = 0;
|
|
Projectile.localAI[1] = 0f;
|
|
}
|
|
}
|
|
|
|
int dust = Dust.NewDust(Projectile.oldPosition + Projectile.oldVelocity, Projectile.width, Projectile.height, DustID.CopperCoin, 0f, 0f, 100, default, 1.25f);
|
|
Main.dust[dust].noGravity = true;
|
|
Main.dust[dust].velocity *= 0f;
|
|
Main.dust[dust].noLightEmittence = true;
|
|
}
|
|
|
|
public override Color? GetAlpha(Color lightColor) => new Color(byte.MaxValue, byte.MaxValue, 128);
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
if (Projectile.timeLeft > TimeLeft - 5)
|
|
return false;
|
|
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2);
|
|
return false;
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<ElementalMix>(), 30);
|
|
}
|
|
|
|
public override void OnKill(int timeLeft)
|
|
{
|
|
for (int i = 4; i < 31; i++)
|
|
{
|
|
float projOldX = Projectile.oldVelocity.X * (30f / i);
|
|
float projOldY = Projectile.oldVelocity.Y * (30f / i);
|
|
int dust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, DustID.CopperCoin, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f);
|
|
Main.dust[dust].noGravity = true;
|
|
Main.dust[dust].noLightEmittence = true;
|
|
|
|
dust = Dust.NewDust(new Vector2(Projectile.oldPosition.X - projOldX, Projectile.oldPosition.Y - projOldY), 8, 8, DustID.CopperCoin, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f);
|
|
Main.dust[dust].noGravity = true;
|
|
Main.dust[dust].velocity *= 0.1f;
|
|
Main.dust[dust].noLightEmittence = true;
|
|
}
|
|
}
|
|
}
|
|
}
|