Files
CalamityModPublic/Projectiles/Melee/BrimlashProj.cs
T

95 lines
4.0 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
namespace CalamityMod.Projectiles.Melee
{
public class BrimlashProj : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 2;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 20;
Projectile.height = 20;
Projectile.aiStyle = ProjAIStyleID.Beam;
AIType = ProjectileID.LightBeam;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.penetrate = -1;
Projectile.timeLeft = 300;
Projectile.DamageType = DamageClass.Melee;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 15;
}
public override void AI()
{
Projectile.velocity *= 0.99f;
if (Projectile.velocity.Length() < 3f)
{
Projectile.Kill();
}
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f);
int num458 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f);
Main.dust[num458].noGravity = true;
Main.dust[num458].velocity *= 0.5f;
Main.dust[num458].velocity += Projectile.velocity * 0.1f;
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(200, 200, 200, Projectile.alpha);
}
public override bool PreDraw(ref Color lightColor)
{
if (Projectile.timeLeft > 295)
return false;
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
public override void Kill(int timeLeft)
{
SoundEngine.PlaySound(SoundID.Item10, Projectile.position);
int num3;
for (int num795 = 4; num795 < 31; num795 = num3 + 1)
{
float num796 = Projectile.oldVelocity.X * (30f / (float)num795);
float num797 = Projectile.oldVelocity.Y * (30f / (float)num795);
int num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, (int)CalamityDusts.Brimstone, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.8f);
Main.dust[num798].noGravity = true;
Dust dust = Main.dust[num798];
dust.velocity *= 0.5f;
num798 = Dust.NewDust(new Vector2(Projectile.oldPosition.X - num796, Projectile.oldPosition.Y - num797), 8, 8, (int)CalamityDusts.Brimstone, Projectile.oldVelocity.X, Projectile.oldVelocity.Y, 100, default, 1.4f);
dust = Main.dust[num798];
dust.velocity *= 0.05f;
num3 = num795;
}
if (Projectile.owner == Main.myPlayer)
{
for (int i = 0; i < 3; i++)
{
Vector2 velocity = ((MathHelper.TwoPi * i / 3f) + Projectile.velocity.ToRotation()).ToRotationVector2() * 4f;
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType<Brimlash2>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
}
}
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 180);
}
}