128 lines
5.5 KiB
C#
128 lines
5.5 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class FrigidflashBoltProjectile : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
// DisplayName.SetDefault("Frigidflash Bolt");
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 20;
|
|
Projectile.height = 20;
|
|
Projectile.friendly = true;
|
|
Projectile.alpha = 255;
|
|
Projectile.penetrate = 5;
|
|
Projectile.timeLeft = 480;
|
|
Projectile.DamageType = DamageClass.Magic;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 10;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (Projectile.alpha > 0)
|
|
{
|
|
Projectile.alpha -= 25;
|
|
if (Projectile.alpha < 0)
|
|
Projectile.alpha = 0;
|
|
}
|
|
Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.25f / 255f);
|
|
for (int num92 = 0; num92 < 2; num92++)
|
|
{
|
|
float num93 = Projectile.velocity.X / 3f * (float)num92;
|
|
float num94 = Projectile.velocity.Y / 3f * (float)num92;
|
|
int num95 = 4;
|
|
int fireDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)num95, Projectile.position.Y + (float)num95), Projectile.width - num95 * 2, Projectile.height - num95 * 2, 174, 0f, 0f, 100, default, 1.2f);
|
|
Dust dust = Main.dust[fireDust];
|
|
dust.noGravity = true;
|
|
dust.velocity *= 0.1f;
|
|
dust.velocity += Projectile.velocity * 0.1f;
|
|
dust.position.X -= num93;
|
|
dust.position.Y -= num94;
|
|
}
|
|
if (Main.rand.NextBool(10))
|
|
{
|
|
int num97 = 4;
|
|
int fireDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)num97, Projectile.position.Y + (float)num97), Projectile.width - num97 * 2, Projectile.height - num97 * 2, 174, 0f, 0f, 100, default, 0.6f);
|
|
Main.dust[fireDustSmol].velocity *= 0.25f;
|
|
Main.dust[fireDustSmol].velocity += Projectile.velocity * 0.5f;
|
|
}
|
|
for (int num105 = 0; num105 < 2; num105++)
|
|
{
|
|
float num99 = Projectile.velocity.X / 3f * (float)num105;
|
|
float num100 = Projectile.velocity.Y / 3f * (float)num105;
|
|
int num101 = 4;
|
|
int frostDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)num101, Projectile.position.Y + (float)num101), Projectile.width - num101 * 2, Projectile.height - num101 * 2, 92, 0f, 0f, 100, default, 1.2f);
|
|
Dust dust = Main.dust[frostDust];
|
|
dust.noGravity = true;
|
|
dust.velocity *= 0.1f;
|
|
dust.velocity += Projectile.velocity * 0.1f;
|
|
dust.position.X -= num99;
|
|
dust.position.Y -= num100;
|
|
}
|
|
if (Main.rand.NextBool(10))
|
|
{
|
|
int num103 = 4;
|
|
int frostDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)num103, Projectile.position.Y + (float)num103), Projectile.width - num103 * 2, Projectile.height - num103 * 2, 92, 0f, 0f, 100, default, 0.6f);
|
|
Main.dust[frostDustSmol].velocity *= 0.25f;
|
|
Main.dust[frostDustSmol].velocity += Projectile.velocity * 0.5f;
|
|
}
|
|
Projectile.rotation += 0.3f * (float)Projectile.direction;
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
|
return false;
|
|
}
|
|
|
|
public override bool OnTileCollide(Vector2 oldVelocity)
|
|
{
|
|
Projectile.penetrate--;
|
|
if (Projectile.penetrate <= 0)
|
|
{
|
|
Projectile.Kill();
|
|
}
|
|
else
|
|
{
|
|
if (Projectile.velocity.X != oldVelocity.X)
|
|
{
|
|
Projectile.velocity.X = -oldVelocity.X;
|
|
}
|
|
if (Projectile.velocity.Y != oldVelocity.Y)
|
|
{
|
|
Projectile.velocity.Y = -oldVelocity.Y;
|
|
}
|
|
SoundEngine.PlaySound(SoundID.Item10, Projectile.position);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item27, Projectile.position);
|
|
for (int k = 0; k < 3; k++)
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 174, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 92, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
target.AddBuff(BuffID.OnFire3, 180);
|
|
target.AddBuff(BuffID.Frostburn, 180);
|
|
}
|
|
}
|
|
}
|