Files
CalamityModPublic/Projectiles/Rogue/AntumbraShardProjectile.cs
T

92 lines
3.4 KiB
C#

using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class AntumbraShardProjectile : ModProjectile
{
public override string Texture => "CalamityMod/Items/Weapons/Rogue/ShardofAntumbra";
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Antumbra Shard");
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 20;
Projectile.height = 20;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.penetrate = -1;
Projectile.extraUpdates = 1;
Projectile.aiStyle = ProjAIStyleID.StickProjectile;
Projectile.timeLeft = 600;
AIType = ProjectileID.BoneJavelin;
Projectile.DamageType = RogueDamageClass.Instance;
}
public override void AI()
{
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f);
if (Projectile.spriteDirection == -1)
{
Projectile.rotation -= 1.57f;
}
if (Main.rand.NextBool(3))
{
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 62, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f);
}
if (Projectile.timeLeft % 12 == 0)
{
if (Projectile.owner == Main.myPlayer)
{
if (Projectile.Calamity().stealthStrike)
{
int star = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f, ModContent.ProjectileType<EmpyreanStellarDetritus>(), (int)(Projectile.damage * 0.5), Projectile.knockBack, Projectile.owner, 0f, 0f);
Main.projectile[star].DamageType = RogueDamageClass.Instance;
}
}
}
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
public override void Kill(int timeLeft)
{
if (Main.rand.NextBool(2))
{
Item.NewItem(Projectile.GetSource_DropAsItem(), (int)Projectile.position.X, (int)Projectile.position.Y, Projectile.width, Projectile.height, ModContent.ItemType<ShardofAntumbra>());
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
Projectile.damage /= 2;
if (Projectile.damage < 1)
{
Projectile.damage = 1;
}
target.immune[Projectile.owner] = 2;
}
public override void OnHitPvp(Player target, int damage, bool crit)
{
Projectile.damage /= 2;
if (Projectile.damage < 1)
{
Projectile.damage = 1;
}
}
}
}