79 lines
3.0 KiB
C#
79 lines
3.0 KiB
C#
using CalamityMod.Projectiles.Healing;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
|
|
namespace CalamityMod.Projectiles.Rogue
|
|
{
|
|
public class ShinobiBladeProjectile : ModProjectile
|
|
{
|
|
public override string Texture => "CalamityMod/Items/Weapons/Rogue/ShinobiBlade";
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Shinobi Blade");
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 3;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = Projectile.height = 16;
|
|
Projectile.friendly = true;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 300;
|
|
Projectile.DamageType = RogueDamageClass.Instance;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt();
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.PiOver2 * Projectile.spriteDirection;
|
|
|
|
if (Main.rand.NextBool(5))
|
|
{
|
|
int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 15);
|
|
Main.dust[dust].noGravity = true;
|
|
}
|
|
}
|
|
|
|
public override bool OnTileCollide(Vector2 oldVelocity)
|
|
{
|
|
Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height);
|
|
SoundEngine.PlaySound(SoundID.Dig, Projectile.position);
|
|
Projectile.Kill();
|
|
return false;
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
|
return false;
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
|
{
|
|
if (target.life <= 0)
|
|
CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], 10, ModContent.ProjectileType<ShinobiHealOrb>(), 1200f, 0f);
|
|
}
|
|
|
|
public override void OnHitPvp(Player target, int damage, bool crit)
|
|
{
|
|
if (target.statLife <= 0)
|
|
CalamityGlobalProjectile.SpawnLifeStealProjectile(Projectile, Main.player[Projectile.owner], 10, ModContent.ProjectileType<ShinobiHealOrb>(), 1200f, 0f);
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
int dustType = 42;
|
|
int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X / 2, Projectile.velocity.Y / 2, 0, default, 1.5f);
|
|
Main.dust[dust].noGravity = true;
|
|
}
|
|
}
|
|
}
|
|
}
|