using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace ForgottenWawiTech.Content.Projectiles.Transcendent { public class TranscendentRailBolt : ModProjectile { public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 15; ProjectileID.Sets.TrailingMode[Type] = 3; } public override string Texture => "ForgottenWawiTech/Assets/PlaceholderProj"; public override void SetDefaults() { Projectile.width = 14; Projectile.height = 14; Projectile.friendly = true; Projectile.hostile = false; Projectile.penetrate = 8; Projectile.timeLeft = 240; Projectile.tileCollide = false; Projectile.extraUpdates = 3; Projectile.DamageType = DamageClass.Ranged; Projectile.ignoreWater = true; Projectile.light = 0.6f; } public override void AI() { if (Projectile.localAI[0] == 0f) { Projectile.localAI[0] = 1f; SoundEngine.PlaySound(SoundID.Item72, Projectile.position); } Lighting.AddLight(Projectile.Center, 0.5f, 0.55f, 0.8f); Projectile.rotation = Projectile.velocity.ToRotation(); if (Main.rand.NextBool(3)) { Vector2 dustVelocity = Projectile.velocity * 0.2f; Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Electric, dustVelocity.X, dustVelocity.Y, 150, default, 1.2f); dust.noGravity = true; } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { SplitIntoShards(); } public override void OnKill(int timeLeft) { SplitIntoShards(); for (int i = 0; i < 8; i++) { Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.BlueCrystalShard, Projectile.velocity.X * 0.4f, Projectile.velocity.Y * 0.4f, 100, default, 1.3f); dust.noGravity = true; } } private void SplitIntoShards() { if (Projectile.owner != Main.myPlayer) return; int shardCount = 3; for (int i = 0; i < shardCount; i++) { Vector2 velocity = Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(25f)) * 0.7f; if (velocity.LengthSquared() < 1f) { velocity = new Vector2(0f, -6f); } Projectile.NewProjectile( Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.7f), Projectile.knockBack * 0.6f, Projectile.owner); } } } }