126 lines
5.4 KiB
C#
126 lines
5.4 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
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.magic = true;
|
|
}
|
|
|
|
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(SpriteBatch spriteBatch, Color lightColor)
|
|
{
|
|
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 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;
|
|
}
|
|
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 10);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 27);
|
|
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, int damage, float knockback, bool crit)
|
|
{
|
|
target.AddBuff(BuffID.OnFire, 300);
|
|
target.AddBuff(BuffID.Frostburn, 300);
|
|
}
|
|
}
|
|
}
|