72 lines
2.4 KiB
C#
72 lines
2.4 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class Shadowbolt : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Magic";
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 4;
|
|
Projectile.height = 4;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Magic;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = 6;
|
|
Projectile.extraUpdates = 100;
|
|
Projectile.timeLeft = 300;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 10;
|
|
}
|
|
|
|
public override bool OnTileCollide(Vector2 oldVelocity)
|
|
{
|
|
Projectile.damage = (int)(Projectile.damage * 1.15);
|
|
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;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
|
|
{
|
|
Projectile.damage = (int)(Projectile.damage * 1.15);
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.localAI[0] += 1f;
|
|
if (Projectile.localAI[0] > 9f)
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
Vector2 projPos = Projectile.position;
|
|
projPos -= Projectile.velocity * ((float)i * 0.25f);
|
|
Projectile.alpha = 255;
|
|
int shadowDust = Dust.NewDust(projPos, 1, 1, 173, 0f, 0f, 0, default, 1f);
|
|
Main.dust[shadowDust].position = projPos;
|
|
Main.dust[shadowDust].scale = (float)Main.rand.Next(70, 110) * 0.013f;
|
|
Main.dust[shadowDust].velocity *= 0.2f;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|