Files
CalamityModPublic/Projectiles/Magic/FabRay.cs
T
DominicKarma42 55e89c9b98 Replaced (hopefully) every magic number with a constant
Note: Does not include item rarities, and appears to shown nonexistant using directive movement in the commit. This does not really affect anything, however.
2020-05-30 17:56:36 -04:00

76 lines
2.5 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Magic
{
public class FabRay : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Ray");
}
public override void SetDefaults()
{
projectile.width = 8;
projectile.height = 8;
projectile.friendly = true;
projectile.magic = true;
projectile.penetrate = 20;
projectile.extraUpdates = 100;
projectile.timeLeft = 600;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 0;
}
public override void AI()
{
Lighting.AddLight(projectile.Center, 0.2f, 0.01f, 0.1f);
projectile.localAI[1] += 1f;
if (projectile.localAI[1] >= 9f && projectile.owner == Main.myPlayer)
{
projectile.localAI[1] = 0f;
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType<FabOrb>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
}
projectile.localAI[0] += 1f;
if (projectile.localAI[0] > 16f)
{
for (int num447 = 0; num447 < 2; num447++)
{
Vector2 vector33 = projectile.position;
vector33 -= projectile.velocity * ((float)num447 * 0.25f);
int num448 = Dust.NewDust(vector33, 1, 1, 234, 0f, 0f, 0, default, 1.25f);
Main.dust[num448].noGravity = true;
Main.dust[num448].noLight = true;
Main.dust[num448].position = vector33;
Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f;
Main.dust[num448].velocity *= 0.1f;
}
}
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
projectile.penetrate--;
if (projectile.penetrate <= 0)
{
projectile.Kill();
}
else
{
projectile.ai[0] += 0.1f;
if (projectile.velocity.X != oldVelocity.X)
{
projectile.velocity.X = -oldVelocity.X;
}
if (projectile.velocity.Y != oldVelocity.Y)
{
projectile.velocity.Y = -oldVelocity.Y;
}
}
return false;
}
}
}