83 lines
2.6 KiB
C#
83 lines
2.6 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class VisceraBeam : ModProjectile
|
|
{
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
public float healAmt = 1f;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Viscera");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 4;
|
|
Projectile.height = 4;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Magic;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = 9;
|
|
Projectile.extraUpdates = 100;
|
|
Projectile.timeLeft = 300;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 5;
|
|
}
|
|
|
|
public override bool OnTileCollide(Vector2 oldVelocity)
|
|
{
|
|
healAmt *= 1.25f;
|
|
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 OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
|
{
|
|
if (!target.canGhostHeal || Main.player[Projectile.owner].moonLeech)
|
|
return;
|
|
|
|
healAmt *= 1.25f;
|
|
Player player = Main.player[Projectile.owner];
|
|
player.statLife += (int)healAmt;
|
|
player.HealEffect((int)healAmt);
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.localAI[0] += 1f;
|
|
if (Projectile.localAI[0] > 9f)
|
|
{
|
|
for (int num447 = 0; num447 < 4; num447++)
|
|
{
|
|
Vector2 vector33 = Projectile.position;
|
|
vector33 -= Projectile.velocity * ((float)num447 * 0.25f);
|
|
int num448 = Dust.NewDust(vector33, 1, 1, 5, 0f, 0f, 0, default, 1f);
|
|
Main.dust[num448].position = vector33;
|
|
Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f;
|
|
Main.dust[num448].velocity *= 0.1f;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|