70 lines
2.5 KiB
C#
70 lines
2.5 KiB
C#
using CalamityMod.Buffs.StatDebuffs;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class SlagRound : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Ranged";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.TrailCacheLength[Type] = 3;
|
|
ProjectileID.Sets.TrailingMode[Type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 4;
|
|
Projectile.height = 4;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Ranged;
|
|
Projectile.penetrate = 1;
|
|
Projectile.aiStyle = ProjAIStyleID.Arrow;
|
|
Projectile.extraUpdates = 3;
|
|
AIType = ProjectileID.Bullet;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.localAI[0] += 1f;
|
|
if (Projectile.localAI[0] > 4f)
|
|
{
|
|
Vector2 dspeed = -Projectile.velocity * 0.7f;
|
|
int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Sand, 0f, 0f, 100, default, 1f);
|
|
Main.dust[dust].noGravity = true;
|
|
Main.dust[dust].velocity = dspeed;
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, lightColor);
|
|
return false;
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<ArmorCrunch>(), 120);
|
|
}
|
|
|
|
public override void OnKill(int timeLeft)
|
|
{
|
|
for (int k = 0; k < 5; k++)
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Sand, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
|
|
}
|
|
if (Projectile.owner == Main.myPlayer)
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
Vector2 velocity = ((MathHelper.TwoPi * i / 4f) - (MathHelper.Pi / 2f - Projectile.velocity.ToRotation())).ToRotationVector2() * 3.5f;
|
|
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType<FossilShard>(), (int)(Projectile.damage * 0.35), Projectile.knockBack, Projectile.owner);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|