83 lines
2.9 KiB
C#
83 lines
2.9 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Rogue
|
|
{
|
|
public class SylvanSlash : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Slash");
|
|
ProjectileID.Sets.TrailCacheLength[projectile.type] = 10;
|
|
ProjectileID.Sets.TrailingMode[projectile.type] = 1;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 30;
|
|
projectile.height = 30;
|
|
projectile.friendly = true;
|
|
projectile.ignoreWater = true;
|
|
projectile.Calamity().rogue = true;
|
|
projectile.penetrate = 2;
|
|
projectile.alpha = 120;
|
|
projectile.timeLeft = 200;
|
|
projectile.usesLocalNPCImmunity = true;
|
|
projectile.localNPCHitCooldown = 10;
|
|
projectile.tileCollide = false;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (projectile.localAI[0] == 0f)
|
|
{
|
|
Main.PlaySound(SoundID.Item92, projectile.position);
|
|
projectile.localAI[0] += 1f;
|
|
}
|
|
Lighting.AddLight(projectile.Center, 0.1f, 1f, 2f);
|
|
projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt();
|
|
projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.ToRadians(90) * projectile.direction;
|
|
projectile.velocity.Y += projectile.ai[0];
|
|
if (Main.rand.NextBool(2))
|
|
{
|
|
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 111, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f);
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
if (projectile.timeLeft > 195)
|
|
return false;
|
|
|
|
CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 2);
|
|
return false;
|
|
}
|
|
|
|
public override Color? GetAlpha(Color lightColor)
|
|
{
|
|
return new Color(200, 200, 200, projectile.alpha);
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
for (int k = 0; k < 3; k++)
|
|
{
|
|
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 111, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f);
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
|
{
|
|
projectile.velocity *= 0.5f;
|
|
}
|
|
|
|
public override void OnHitPvp(Player target, int damage, bool crit)
|
|
{
|
|
projectile.velocity *= 0.5f;
|
|
}
|
|
}
|
|
}
|